diff --git a/R/archive.R b/R/archive.R index 07394d9d..e877d397 100644 --- a/R/archive.R +++ b/R/archive.R @@ -626,7 +626,7 @@ print.epi_archive <- function(x, ..., class = TRUE, methods = TRUE) { #' epix_slide( #' .f = ~ mean(.x$case_rate_7d_av), #' .before = 2, -#' .ref_time_values = as.Date("2020-06-11") + 0:2, +#' .versions = as.Date("2020-06-11") + 0:2, #' .new_col_name = "case_rate_3d_av" #' ) %>% #' ungroup() diff --git a/R/grouped_epi_archive.R b/R/grouped_epi_archive.R index 1984dae2..3bcb7254 100644 --- a/R/grouped_epi_archive.R +++ b/R/grouped_epi_archive.R @@ -224,13 +224,20 @@ epix_slide.grouped_epi_archive <- function( # early development versions and much more likely to be clutter than # informative in the signature. provided_args <- rlang::call_args_names(rlang::call_match()) - if (any(provided_args %in% c("x", "f", "before", "ref_time_values", "new_col_name", "all_versions"))) { + if (any(provided_args %in% c( + "x", "f", "before", "new_col_name", "all_versions", + ))) { cli::cli_abort( - "epix_slide: you are using one of the following old argument names: `x`, `f`, `before`, `ref_time_values`, - `new_col_name`, `all_versions`. Please use the new names: `.x`, `.f`, `.before`, `.ref_time_values`, + "epix_slide: you are using one of the following old argument names: `x`, `f`, `before`, + `new_col_name`, `all_versions`. Please use the new names: `.x`, `.f`, `.before`, `.new_col_name`, `.all_versions`." ) } + if (any(provided_args %in% c("ref_time_values", ".ref_time_values"))) { + cli::cli_abort( + "epix_slide: the argument `ref_time_values` is deprecated. Please use `.versions` instead." + ) + } if ("group_by" %in% provided_args) { cli_abort(" The `group_by` argument to `slide` has been removed; please use diff --git a/R/methods-epi_archive.R b/R/methods-epi_archive.R index 7ea47a1e..be34211b 100644 --- a/R/methods-epi_archive.R +++ b/R/methods-epi_archive.R @@ -654,7 +654,7 @@ epix_detailed_restricted_mutate <- function(.data, ...) { #' in the archive is "day", and the `.ref_time_value` is January 8, then the #' smallest time_value in the snapshot will be January 1. If missing, then the #' default is no limit on the time values, so the full snapshot is given. -#' @param .ref_time_values Reference time values / versions for sliding +#' @param .versions Reference time values / versions for sliding #' computations; each element of this vector serves both as the anchor point #' for the `time_value` window for the computation and the `max_version` #' `epix_as_of` which we fetch data in this window. If missing, then this will @@ -712,7 +712,7 @@ epix_detailed_restricted_mutate <- function(.data, ...) { #' computations are allowed more flexibility in their outputs than in #' `epi_slide`, we can't guess a good representation for missing computations #' for excluded group-`.ref_time_value` pairs. -#' 76. The `.ref_time_values` default for `epix_slide` is based on making an +#' 76. The `.versions` default for `epix_slide` is based on making an #' evenly-spaced sequence out of the `version`s in the `DT` plus the #' `versions_end`, rather than the `time_value`s. #' @@ -731,7 +731,7 @@ epix_detailed_restricted_mutate <- function(.data, ...) { #' library(dplyr) #' #' # Reference time points for which we want to compute slide values: -#' ref_time_values <- seq(as.Date("2020-06-01"), +#' versions <- seq(as.Date("2020-06-01"), #' as.Date("2020-06-15"), #' by = "1 day" #' ) @@ -743,7 +743,7 @@ epix_detailed_restricted_mutate <- function(.data, ...) { #' epix_slide( #' .f = ~ mean(.x$case_rate_7d_av), #' .before = 2, -#' .ref_time_values = ref_time_values, +#' .versions = versions, #' .new_col_name = "case_rate_7d_av_recent_av" #' ) %>% #' ungroup() @@ -777,7 +777,7 @@ epix_detailed_restricted_mutate <- function(.data, ...) { #' ) #' }, #' .before = 5, .all_versions = FALSE, -#' .ref_time_values = ref_time_values +#' .versions = versions #' ) %>% #' ungroup() %>% #' arrange(geo_value, time_value) @@ -812,7 +812,7 @@ epix_detailed_restricted_mutate <- function(.data, ...) { #' ) #' }, #' .before = 5, .all_versions = TRUE, -#' .ref_time_values = ref_time_values +#' .versions = versions #' ) %>% #' ungroup() %>% #' # Focus on one geo_value so we can better see the columns above: diff --git a/vignettes/advanced.Rmd b/vignettes/advanced.Rmd index f66b0494..65f9ce05 100644 --- a/vignettes/advanced.Rmd +++ b/vignettes/advanced.Rmd @@ -106,7 +106,7 @@ edf %>% mutate(version = time_value) %>% as_epi_archive() %>% group_by(geo_value) %>% - epix_slide(x_2dav = mean(x), .before = 1, .ref_time_values = as.Date("2020-06-02")) %>% + epix_slide(x_2dav = mean(x), .before = 1, .versions = as.Date("2020-06-02")) %>% ungroup() edf %>% @@ -429,7 +429,7 @@ k_week_ahead <- function(x, ahead = 7, as_of = TRUE) { fc = prob_arx(.data$percent_cli, .data$case_rate_7d_av, .data$geo_value, .data$time_value, args = prob_arx_args(ahead = ahead) ), - .before = 219, .ref_time_values = fc_time_values + .before = 219, .versions = fc_time_values ) %>% mutate( target_date = .data$time_value + ahead, as_of = TRUE, diff --git a/vignettes/archive.Rmd b/vignettes/archive.Rmd index 1f5ee1e3..07413126 100644 --- a/vignettes/archive.Rmd +++ b/vignettes/archive.Rmd @@ -346,7 +346,7 @@ z <- x %>% group_by(geo_value) %>% epix_slide( fc = prob_arx(x = percent_cli, y = case_rate_7d_av), .before = 119, - .ref_time_values = fc_time_values + .versions = fc_time_values ) %>% ungroup() @@ -383,7 +383,7 @@ k_week_ahead <- function(x, ahead = 7, as_of = TRUE) { group_by(.data$geo_value) %>% epix_slide( fc = prob_arx(.data$percent_cli, .data$case_rate_7d_av, ahead = ahead), .before = 119, - .ref_time_values = fc_time_values + .versions = fc_time_values ) %>% mutate(target_date = .data$time_value + ahead, as_of = TRUE) %>% ungroup() @@ -392,7 +392,7 @@ k_week_ahead <- function(x, ahead = 7, as_of = TRUE) { group_by(.data$geo_value) %>% epi_slide( fc = prob_arx(.data$percent_cli, .data$case_rate_7d_av, ahead = ahead), .window_size = 120, - .ref_time_values = fc_time_values + .versions = fc_time_values ) %>% mutate(target_date = .data$time_value + ahead, as_of = FALSE) %>% ungroup()