From 1dd7882a01ee190c4aa00e0de33521d42020424a Mon Sep 17 00:00:00 2001 From: Fonti Kar Date: Mon, 11 Nov 2024 13:49:53 +1100 Subject: [PATCH 1/2] Added some global variables --- R/austraits-package.R | 98 +++++++++++++++++++++++------------------ man/flatten_database.Rd | 6 +++ 2 files changed, 62 insertions(+), 42 deletions(-) diff --git a/R/austraits-package.R b/R/austraits-package.R index 21658b8..cfd5fc7 100644 --- a/R/austraits-package.R +++ b/R/austraits-package.R @@ -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" +) ) diff --git a/man/flatten_database.Rd b/man/flatten_database.Rd index feb5ffd..8d272cd 100644 --- a/man/flatten_database.Rd +++ b/man/flatten_database.Rd @@ -8,6 +8,12 @@ flatten_database(database) } \arguments{ \item{database}{A traits.build database} + +\item{format}{} + +\item{vars}{list} + +\item{include_description}{logical} } \value{ A table combining information in 7 traits.build relational tables: traits, locations, contexts, methods, taxa, taxonomic_updates, and contributors From ecbd85d2d1364c521790433ce1a55f7d8c3f7fab Mon Sep 17 00:00:00 2001 From: Fonti Kar Date: Mon, 11 Nov 2024 13:56:01 +1100 Subject: [PATCH 2/2] Reduce line width --- R/extract_data.R | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/R/extract_data.R b/R/extract_data.R index 8c4f61e..f8cf8be 100644 --- a/R/extract_data.R +++ b/R/extract_data.R @@ -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) { @@ -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 @@ -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 )