Skip to content

Commit

Permalink
Get rid of tidyselect
Browse files Browse the repository at this point in the history
  • Loading branch information
Bisaloo committed Dec 1, 2021
1 parent 3f5c115 commit fe79373
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 14 deletions.
1 change: 0 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ Imports:
rlang,
stringr,
tidyr (>= 1.0.0),
tidyselect,
vroom,
xml2
Suggests:
Expand Down
8 changes: 3 additions & 5 deletions R/Lithuania.R
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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)]

Expand Down Expand Up @@ -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(
Expand All @@ -354,7 +352,7 @@ Lithuania <- R6::R6Class("Lithuania",
) %>%
summarise(
across(
tidyselect::vars_select_helpers$where(is.numeric),
where(is.numeric),
sum
)
) %>%
Expand Down
10 changes: 4 additions & 6 deletions R/processing.R
Original file line number Diff line number Diff line change
Expand Up @@ -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_")) %>%
Expand All @@ -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",
Expand All @@ -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")
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions R/shared-methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 4 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")

0 comments on commit fe79373

Please sign in to comment.