--- title: BETYdb Tutorial author: Scott Chamberlain date: "2020-08-25" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{BETYdb Tutorial} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- [BETYdb](https://www.betydb.org/) is the _Biofuel Ecophysiological Traits and Yields Database_. You can get many different types of data from this database, including trait data. Function setup: All functions are prefixed with `betydb_`. Plural function names like `betydb_traits()` accept parameters and always give back a data.frame, while singlur function names like `betydb_trait()` accept an ID and give back a list. The idea with the functions with plural names is to search for either traits, species, etc., and with the singular function names to get data by one or more IDs. ## Load traits ```r library("traits") ``` ## Traits Get trait data for _Miscanthus giganteus_ ```r out <- betydb_search(query = "Switchgrass Yield") ``` Summarise data from the output `data.frame` ```r suppressPackageStartupMessages(library("dplyr")) out %>% group_by(id) %>% summarise(mean_result = mean(as.numeric(mean), na.rm = TRUE)) %>% arrange(desc(mean_result)) ``` ``` #> # A tibble: 449 x 2 #> id mean_result #> #> 1 1666 27.4 #> 2 16845 27 #> 3 1669 26.4 #> 4 16518 26 #> 5 1663 25.4 #> 6 16742 25 #> 7 1594 24.8 #> 8 1674 22.7 #> 9 1606 22.5 #> 10 1665 22.5 #> # … with 439 more rows ``` Single trait ```r betydb_trait(id = 10) ``` ``` #> # A tibble: 1 x 13 #> id description units notes created_at updated_at name max min #> #> 1 10 Leaf Perce… perc… 2011-06-0… leafN 10 0.02 #> # … with 4 more variables: standard_name , standard_units , #> # label , type ``` ## Species Single species, _Acacia karroothorn_ ```r betydb_specie(id = 10) ``` ``` #> # A tibble: 1 x 10 #> id spcd genus species scientificname commonname notes created_at #> #> 1 10 Acac… karroo Acacia karroo karrootho… #> # … with 2 more variables: updated_at , acceptedsymbol ``` ## Citations Get citatons searching for _Miscanthus_ ```r betydb_citation(10) ``` ``` #> # A tibble: 1 x 13 #> id author year title journal vol pg url pdf created_at updated_at #> #> 1 10 Casler 2003 Cult… Crop S… 43 2226… http… http… #> # … with 2 more variables: doi , user_id ``` ## Sites Single site ```r betydb_site(id = 1) ``` ``` #> # A tibble: 1 x 8 #> city state country notes sitename greenhouse geometry time_zone #> #> 1 Aliart… GR Aliartos FALSE POINT (23.17 38.3… Europe/Ath… ```