From fe79373581296f55cba7b00b92b6cfdbc4273da2 Mon Sep 17 00:00:00 2001 From: Hugo Gruson Date: Wed, 1 Dec 2021 10:43:16 +0100 Subject: [PATCH] Get rid of tidyselect --- DESCRIPTION | 1 - R/Lithuania.R | 8 +++----- R/processing.R | 10 ++++------ R/shared-methods.R | 3 +-- R/utils.R | 4 ++++ 5 files changed, 12 insertions(+), 14 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 6d2d75b1..89ec6f9b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -100,7 +100,6 @@ Imports: rlang, stringr, tidyr (>= 1.0.0), - tidyselect, vroom, xml2 Suggests: diff --git a/R/Lithuania.R b/R/Lithuania.R index a1b891fe..db931df0 100644 --- a/R/Lithuania.R +++ b/R/Lithuania.R @@ -184,8 +184,7 @@ Lithuania <- R6::R6Class("Lithuania", #' @description Common data cleaning for both levels #' # nolint start - #' @importFrom dplyr mutate group_by summarise if_else filter select bind_rows rename left_join everything across lead - #' @importFrom tidyselect all_of + #' @importFrom dplyr mutate group_by summarise if_else filter select bind_rows rename left_join everything across lead all_of #' @importFrom lubridate as_date # nolint end clean_common = function() { @@ -244,7 +243,7 @@ Lithuania <- R6::R6Class("Lithuania", # or qualitative) sum_cols <- names(select( self$data$raw$main, - "population":tidyselect::last_col() + "population":dplyr::last_col() )) sum_cols <- sum_cols[!grepl("prc|map_colors", sum_cols)] @@ -345,7 +344,6 @@ Lithuania <- R6::R6Class("Lithuania", #' provided by the source at the level 2 (municipality) regional level. #' #' @importFrom dplyr group_by summarise ungroup full_join across if_else - #' @importFrom tidyselect vars_select_helpers clean_level_1 = function() { self$data$clean <- self$data$clean %>% group_by( @@ -354,7 +352,7 @@ Lithuania <- R6::R6Class("Lithuania", ) %>% summarise( across( - tidyselect::vars_select_helpers$where(is.numeric), + where(is.numeric), sum ) ) %>% diff --git a/R/processing.R b/R/processing.R index 2d469171..23a0b2ad 100644 --- a/R/processing.R +++ b/R/processing.R @@ -51,7 +51,7 @@ set_negative_values_to_zero <- function(data) { #' @family compulsory_processing #' @concept compulsory_processing #' @importFrom tidyr complete full_seq nesting -#' @importFrom tidyselect starts_with +#' @importFrom dplyr starts_with #' @importFrom rlang !!! syms fill_empty_dates_with_na <- function(data) { regions <- select(data, starts_with("level_")) %>% @@ -75,7 +75,7 @@ fill_empty_dates_with_na <- function(data) { #' @family compulsory_processing #' @concept compulsory_processing #' @importFrom tidyr fill -#' @importFrom tidyselect all_of +#' @importFrom dplyr all_of complete_cumulative_columns <- function(data) { cumulative_col_names <- c( "deaths_total", "cases_total", "recovered_total", @@ -98,10 +98,9 @@ complete_cumulative_columns <- function(data) { #' @return A data frame with extra columns if required #' @family compulsory_processing #' @concept compulsory_processing -#' @importFrom dplyr mutate group_by_at arrange vars starts_with lag +#' @importFrom dplyr mutate group_by_at arrange vars starts_with lag ends_with #' @importFrom purrr walk2 #' @importFrom tidyr replace_na -#' @importFrom tidyselect ends_with #' @importFrom rlang !! := calculate_columns_from_existing_data <- function(data) { possible_counts <- c("cases", "deaths", "hosp", "recovered", "tested") @@ -220,10 +219,9 @@ run_optional_processing_fns <- function(data, process_fns) { #' processing steps #' @concept utility #' @family processing -#' @importFrom dplyr do group_by_at across ungroup select everything arrange +#' @importFrom dplyr do group_by_at across ungroup select everything arrange all_of #' @importFrom dplyr rename #' @importFrom tidyr drop_na -#' @importFrom tidyselect all_of #' @importFrom rlang !!! process_internal <- function(clean_data, level, group_vars, totals = FALSE, localise = TRUE, diff --git a/R/shared-methods.R b/R/shared-methods.R index f4c1bb34..62a88ba8 100644 --- a/R/shared-methods.R +++ b/R/shared-methods.R @@ -351,8 +351,7 @@ DataClass <- R6::R6Class( #' field. #' @param level A character string indicating the level to filter at. #' Defaults to using the `filter_level` field if not specified - #' @importFrom tidyselect all_of - #' @importFrom dplyr select filter pull + #' @importFrom dplyr select filter pull all_of available_regions = function(level) { if (is.null(self$data$clean)) { stop("Data must first be cleaned using the clean method") diff --git a/R/utils.R b/R/utils.R index 9fd7364d..6f845b2e 100644 --- a/R/utils.R +++ b/R/utils.R @@ -303,3 +303,7 @@ make_new_data_source <- function(source, type = "subnational", ) make_github_workflow(source) } + +# Hack to work around the fact that `where()` is not exported +# (https://github.com/r-lib/tidyselect/issues/201) +utils::globalVariables("where")