-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update previous join_ functions and create new database_create_combined_table function to replace join_all. This includes: Splitting the old join_locations into two functions: join_location_coordinates to explicitly join latitude/longitude and join_location_properties to join location metadata For join_contexts, join_locations and join_contributors offer different output formats: many_columns, single_column_pretty, single_column_json For all functions add option vars = "all", which will add all columns/location properties/context properties. Join_contexts is reworked, using the variant that was developed on traits.build for database_create_combined_table. The old join_contexts is still required for as_wide_table (the combined table currently output via austraits.build API) and has been moved to that file. as_wide_table maintained for now to support austraits.build API, but will be removed in the coming months. --------- Co-authored-by: Daniel Falster <[email protected]>
- Loading branch information
Showing
25 changed files
with
1,033 additions
and
283 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,7 @@ Suggests: | |
ggpointdensity, | ||
ggbeeswarm (>= 0.7.1), | ||
gridExtra, | ||
readr, | ||
scales, | ||
forcats, | ||
viridis, | ||
|
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#' Create combined traits.build table | ||
#' | ||
#' Create a single database output that merges together the information | ||
#' in all relational tables within a traits.build database. | ||
#' Trait measurements are still output in long format (1 row per trait value), | ||
#' but all measurement-related metadata (methods, location properties, context properties, contributors) | ||
#' are now included as additional columns in a single table. | ||
#' | ||
#' @param database A traits.build database | ||
#' | ||
#' @return A table combining information in 7 traits.build relational tables: traits, locations, contexts, methods, taxa, taxonomic_updates, and contributors | ||
#' @export | ||
#' | ||
#' @usage database_create_combined_table(database) | ||
#' | ||
database_create_combined_table <- function(austraits, | ||
format = "single_column_pretty", | ||
vars = list( | ||
location = "all", | ||
context = "all", | ||
contributors = "all", | ||
taxonomy = "all", | ||
taxonomic_updates = "all", | ||
methods = setdiff(names(austraits$methods), c("data_collectors")) | ||
), | ||
include_description = TRUE | ||
) { | ||
# Since `data_collectors` is also merged into the combined_table via the contributors tibble, we don't want the information twice. | ||
|
||
combined_table_relational <- austraits %>% | ||
join_location_coordinates() %>% | ||
join_location_properties(format = format, vars = vars$location) %>% | ||
join_context_properties(format = format, vars = vars$context, include_description = TRUE) %>% | ||
join_methods(vars = vars$methods) %>% | ||
join_contributors(format = format, vars = vars$contributors) %>% | ||
join_taxa(vars = vars$taxonomy) %>% | ||
join_taxonomic_updates(vars = vars$taxonomic_updates) | ||
|
||
combined_table <- combined_table_relational$traits | ||
} |
Oops, something went wrong.