Skip to content

Commit

Permalink
Merge branch 'generalise_extract_off_develop' of https://github.com/t…
Browse files Browse the repository at this point in the history
…raitecoevo/austraits into generalise_extract_off_develop
  • Loading branch information
ehwenk committed Nov 11, 2024
2 parents 9b825af + ecbd85d commit 5870716
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 46 deletions.
98 changes: 56 additions & 42 deletions R/austraits-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,46 +17,60 @@ if(getRversion() >= "2.15.1") utils::globalVariables(c(".", "dplyr::n()"))
## usethis namespace: end
NULL

utils::globalVariables(c("..density..",
".data",
"Group",
"abort",
"australia",
"colour",
"context",
"context_name",
"context_property",
"dataset_id",
"latitude (deg)",
"link_id",
"link_vals",
"location_name",
"location_property",
"longitude (deg)",
"method_context_id",
"method_id",
"n",
"n_vals",
"n_value_type",
"observation_id",
"original_name",
"percent",
"percent_total",
"repeat_measurements_id",
"replicates",
"shapes",
"site_name",
"site_property",
"source_id",
"taxon_name",
"text",
"trait_name",
"value",
"value_type",
"x",
"y",
"publication_date",
"doi",
"relation_type",
"identifier")
utils::globalVariables(c(
"aus_traits",
"..density..",
"description",
".data",
"doi",
"given_name",
"Group",
"abort",
"australia",
"basis_of_value",
"category",
"colour",
"context",
"context_name",
"context_property",
"contributor",
"data",
"dataset_id",
"data_contributors",
"identifier",
"last_name",
"latitude (deg)",
"link_id",
"link_vals",
"location_id",
"location_name",
"location_property",
"location_properties",
"longitude (deg)",
"method_context_id",
"method_id",
"n",
"name",
"n_vals",
"n_value_type",
"observation_id",
"original_name",
"percent",
"percent_total",
"publication_date",
"repeat_measurements_id",
"relation_type",
"replicates",
"shapes",
"site_name",
"site_property",
"source_id",
"taxon_name",
"text",
"trait_name",
"value",
"value_type",
"x",
"y"
)
)
9 changes: 5 additions & 4 deletions R/extract_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
#'
#' @examples
#' \dontrun{
#' extract_data(database = traits.build_database, table = "traits", col = "trait_name", col_value = "leaf_area")
#' extract_data(database = traits.build_database, table = "traits",
#' col = "trait_name", col_value = "leaf_area")
#' }
extract_data <- function(database, table, col, col_value) {

Expand Down Expand Up @@ -155,7 +156,7 @@ extract_data <- function(database, table, col, col_value) {
# Trim traits, based on the columns identified as being common between the traits table and target table
cc_traits <- database[[table[[i]]]] |>
dplyr::slice(found_indicies) |>
dplyr::select(all_of(columns_to_select)) |>
dplyr::select(tidyselect::all_of(columns_to_select)) |>
dplyr::distinct()

# Filtering join
Expand All @@ -175,11 +176,11 @@ extract_data <- function(database, table, col, col_value) {
dplyr::distinct()

cut_traits <- cut_traits |>
dplyr::filter(if_all(everything(), ~ !is.na(.)))
dplyr::filter(dplyr::if_all(tidyselect::everything(), ~ !is.na(.)))

cut_table <- eval(parse(text = tables_tmp$tables_complete_path[[j]])) |>
dplyr::semi_join(cut_traits, by = get(tables_tmp$cookie_cutters[[j]])) %>%
dplyr::rename(link_vals = contains("context_id"))
dplyr::rename(link_vals = tidyselect::contains("context_id"))

assign(paste0("ret_tmp[[\"", tables_tmp$tables_to_cut[[j]], "\"]]"), cut_table )

Expand Down
6 changes: 6 additions & 0 deletions man/flatten_database.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5870716

Please sign in to comment.