Search for traits from BETYdb
Get details about a single item from a table
Usage
betydb_record(
id,
table,
api_version = NULL,
betyurl = NULL,
fmt = NULL,
key = NULL,
user = NULL,
pwd = NULL,
progress = TRUE,
...
)
betydb_trait(
id,
genus = NULL,
species = NULL,
api_version = NULL,
betyurl = NULL,
fmt = "json",
key = NULL,
user = NULL,
pwd = NULL,
progress = TRUE,
...
)
betydb_specie(
id,
genus = NULL,
species = NULL,
api_version = NULL,
betyurl = NULL,
fmt = "json",
key = NULL,
user = NULL,
pwd = NULL,
progress = TRUE,
...
)
betydb_citation(
id,
genus = NULL,
species = NULL,
api_version = NULL,
betyurl = NULL,
fmt = "json",
key = NULL,
user = NULL,
pwd = NULL,
progress = TRUE,
...
)
betydb_site(
id,
api_version = NULL,
betyurl = NULL,
fmt = "json",
key = NULL,
user = NULL,
pwd = NULL,
progress = TRUE,
...
)
betydb_experiment(
id,
api_version = NULL,
betyurl = NULL,
fmt = "json",
key = NULL,
user = NULL,
pwd = NULL,
progress = TRUE,
...
)
Arguments
- id
(integer) One or more ids for a species, site, variable, etc.
- table
(character) Name of the database table with which this ID is associated.
- api_version
(character) Which version of the BETY API should we query? One of "v0" or "beta". Default is
options("betydb_api_version")
if set, otherwise "v0".- betyurl
(string) url to target instance of betydb. Default is
options("betydb_url")
if set, otherwise "https:/www.betydb.org/"- fmt
(character) Format to return data in, one of json, xml, csv. Only json currently supported.
- key
(character) An API key. Use this or user/pwd combo. Save in your
.Rprofile
file asoptions(betydb_key = "your40digitkey")
. Optional- user, pwd
(character) A user name and password. Use a user/pwd combo or an API key. Save in your
.Rprofile
file asoptions(betydb_user = "yournamehere")
andoptions(betydb_pwd = "yourpasswordhere")
. Optional- progress
show progress bar? default:
TRUE
- ...
Curl options passed on to
GET
. Optional- genus
(character) A genus name. Optional
- species
(character) A specific epithet. Optional
Details
BETYdb includes a primary home page (betydb.org) focused on bioenergy crops as well as a network of harmonized databases that support and share data among more focused research programs.
For a list of publicly accessible instances of BETYdb and the urls that can be queried, see https://pecan.gitbooks.io/betydb-documentation/content/distributed_betydb.html
This package queries plant traits, phenotypes, biomass yields, and ecosystem functions. It does not currently interface with the workflow and provenance data that support PEcAn Project (pecanproject.org) and TERRA REF (terraref.org) software.
API documentation: https://pecan.gitbooks.io/betydb-data-access/content/API.html
API endpoints are here: https://www.betydb.org/api/docs
This package currently uses the original 'v0' API by default.
To use a newer version, set api_version
.
Newer versions of the API will support database inserts.
Authentication
Defers to use API key first since it's simpler, but if you don't have an API key, you can supply a username and password.
Functions
Singular functions like betydb_trait
accept an id and additional parameters,
and return a list of variable outputs depending on the inputs.
However, plural functions like betydb_traits
accept query parameters, but not
ids, and always return a single data.frame.
betydb_search("Search terms", ...)
is a convenience wrapper that passes all further arguments to betydb_query(table = "search", search = "Search terms", ...)
. See there for details on possible arguments.
References
API documentation https://pecan.gitbooks.io/betydb-data-access/content/API.html and https://www.betydb.org/api/docs
Examples
if (FALSE) { # \dontrun{
# General Search
out <- betydb_search(query = "Switchgrass Yield")
library("dplyr")
out %>%
group_by(id) %>%
summarise(mean_result = mean(as.numeric(mean), na.rm = TRUE)) %>%
arrange(desc(mean_result))
# Get by ID
## Traits
betydb_trait(id = 10)
## Species
betydb_specie(id = 1)
## Citations
betydb_citation(id = 1)
## Site information
betydb_site(id = 795)
} # }