traits (version 0.1.2)

betydb: Search for traits from BETYdb

Description

Search for traits from BETYdb

Usage

betydb_search(query = "Maple SLA", fmt = "json", key = NULL,
  user = NULL, pwd = NULL, ...)

betydb_trait(id, genus = NULL, species = NULL, fmt = "json", key = NULL, user = NULL, pwd = NULL, ...)

betydb_specie(id, genus = NULL, species = NULL, fmt = "json", key = NULL, user = NULL, pwd = NULL, ...)

betydb_citation(id, genus = NULL, species = NULL, fmt = "json", key = NULL, user = NULL, pwd = NULL, ...)

betydb_site(id, fmt = "json", key = NULL, user = NULL, pwd = NULL, ...)

Arguments

query
Query terms
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 as betydb_key. Optional
user,pwd
(character) A user name and password. Use a user/pwd combo or an API key. Save in your .Rprofile file as betydb_user and betydb_pwd. Optional
...
Curl options passed on to GET. Optional
id
(integer) One or more ids for a species, site, variable, etc.
genus
(character) A genus name. Optional
species
(character) A specific epithet. Optional

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.

Details

Details:

References

API documentation https://www.authorea.com/users/5574/articles/7062

Examples

Run this code
# 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)
## Citations
betydb_site(id = 795)

Run the code above in your browser using DataCamp Workspace