Created
September 28, 2022 21:24
-
-
Save dlebauer/b8a1f873e08e27aed1877d15d97e821c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(traits) | |
library(dplyr) | |
library(ggplot2) | |
options(betydb_url = 'https://www.betydb.org/', | |
betydb_api_version = 'v1' | |
) | |
yields <- betydb_search(result_type = 'yields', genus = 'Panicum', limit = 'none') | |
treatments <- betydb_query(table = 'treatments', limit = 'none') %>% | |
dplyr::mutate(treatment_id = id) %>% | |
dplyr::select(treatment_id, name, definition, control) | |
managements <- betydb_query(table = 'managements', limit = 'none') %>% | |
dplyr::filter(mgmttype %in% c('planting', "planting (plants / m2)", "row_spacing")) %>% | |
dplyr::mutate(management_id = id) %>% | |
dplyr::select(management_id, date, mgmttype, level, units) | |
# now link managements to treatments | |
m <- betydb_query(table = 'managements', associations_mode = 'ids', limit = 'none') | |
managements_treatments <- m %>% | |
select(treatment_id = `associated treatment ids`, management_id = id) %>% | |
tidyr::unnest(cols = c(treatment_id)) | |
planting <- managements %>% | |
left_join(managements_treatments, by = 'management_id') %>% | |
left_join(treatments, by = 'treatment_id') %>% | |
select(date, treatment_id) %>% | |
distinct() | |
y <- yields %>% | |
left_join(planting, by = 'treatment_id') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment