From e7028ef9b6a46e2f44e88ce412bd6153d4f90d71 Mon Sep 17 00:00:00 2001 From: Dmitry Shemetov Date: Wed, 25 Sep 2024 17:15:42 -0700 Subject: [PATCH] doc: fix examples, vignettes, add waldo --- .Rbuildignore | 2 ++ .gitignore | 1 + DESCRIPTION | 3 ++- R/methods-epi_archive.R | 4 ++-- R/outliers.R | 8 +++----- R/slide.R | 2 +- man/detect_outlr_rm.Rd | 3 +-- man/detect_outlr_stl.Rd | 5 ++--- man/epix_slide.Rd | 4 ++-- vignettes/archive.Rmd | 2 +- 10 files changed, 17 insertions(+), 17 deletions(-) diff --git a/.Rbuildignore b/.Rbuildignore index 0582014a6..cb0b7ed2b 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -16,3 +16,5 @@ ^.lintr$ ^DEVELOPMENT.md$ man-roxygen +^.venv$ +^sandbox.R$ \ No newline at end of file diff --git a/.gitignore b/.gitignore index de393a316..8dc001be4 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ docs renv/ renv.lock .Rprofile +sandbox.R \ No newline at end of file diff --git a/DESCRIPTION b/DESCRIPTION index 333bf13cd..790b36a54 100755 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -50,7 +50,8 @@ Imports: tidyselect (>= 1.2.0), tsibble, utils, - vctrs + vctrs, + waldo Suggests: covidcast, devtools, diff --git a/R/methods-epi_archive.R b/R/methods-epi_archive.R index be34211b8..0304d9a60 100644 --- a/R/methods-epi_archive.R +++ b/R/methods-epi_archive.R @@ -731,7 +731,7 @@ epix_detailed_restricted_mutate <- function(.data, ...) { #' library(dplyr) #' #' # Reference time points for which we want to compute slide values: -#' versions <- seq(as.Date("2020-06-01"), +#' versions <- seq(as.Date("2020-06-02"), #' as.Date("2020-06-15"), #' by = "1 day" #' ) @@ -780,7 +780,7 @@ epix_detailed_restricted_mutate <- function(.data, ...) { #' .versions = versions #' ) %>% #' ungroup() %>% -#' arrange(geo_value, time_value) +#' arrange(geo_value, version) #' #' # --- Advanced: --- #' diff --git a/R/outliers.R b/R/outliers.R index 56cac3849..c2187de0a 100644 --- a/R/outliers.R +++ b/R/outliers.R @@ -161,8 +161,7 @@ detect_outlr <- function(x = seq_along(y), y, #' group_by(geo_value) %>% #' mutate(outlier_info = detect_outlr_rm( #' x = time_value, y = cases -#' )) %>% -#' unnest(outlier_info) +#' )) detect_outlr_rm <- function(x = seq_along(y), y, n = 21, log_transform = FALSE, detect_negatives = FALSE, @@ -256,9 +255,8 @@ detect_outlr_rm <- function(x = seq_along(y), y, n = 21, #' group_by(geo_value) %>% #' mutate(outlier_info = detect_outlr_stl( #' x = time_value, y = cases, -#' seasonal_period = 7 -#' )) %>% # weekly seasonality for daily data -#' unnest(outlier_info) +#' seasonal_period = 7 # weekly seasonality for daily data +#' )) detect_outlr_stl <- function(x = seq_along(y), y, n_trend = 21, n_seasonal = 21, diff --git a/R/slide.R b/R/slide.R index 50c8acf42..5a7fbd6aa 100644 --- a/R/slide.R +++ b/R/slide.R @@ -728,7 +728,7 @@ epi_slide_opt <- function( # positions of user-provided `col_names` into string column names. We avoid # using `names(pos)` directly for robustness and in case we later want to # allow users to rename fields via tidyselection. - if (class(quo_get_expr(enquo(.col_names))) == "character") { + if (inherits(quo_get_expr(enquo(.col_names)), "character")) { pos <- eval_select(dplyr::all_of(.col_names), data = .x, allow_rename = FALSE) } else { pos <- eval_select(enquo(.col_names), data = .x, allow_rename = FALSE) diff --git a/man/detect_outlr_rm.Rd b/man/detect_outlr_rm.Rd index 333c4a7b5..b57c44450 100644 --- a/man/detect_outlr_rm.Rd +++ b/man/detect_outlr_rm.Rd @@ -65,6 +65,5 @@ incidence_num_outlier_example \%>\% group_by(geo_value) \%>\% mutate(outlier_info = detect_outlr_rm( x = time_value, y = cases - )) \%>\% - unnest(outlier_info) + )) } diff --git a/man/detect_outlr_stl.Rd b/man/detect_outlr_stl.Rd index 695c2de78..fb69e8da3 100644 --- a/man/detect_outlr_stl.Rd +++ b/man/detect_outlr_stl.Rd @@ -96,7 +96,6 @@ incidence_num_outlier_example \%>\% group_by(geo_value) \%>\% mutate(outlier_info = detect_outlr_stl( x = time_value, y = cases, - seasonal_period = 7 - )) \%>\% # weekly seasonality for daily data - unnest(outlier_info) + seasonal_period = 7 # weekly seasonality for daily data + )) } diff --git a/man/epix_slide.Rd b/man/epix_slide.Rd index 1f3018460..1326cc185 100644 --- a/man/epix_slide.Rd +++ b/man/epix_slide.Rd @@ -170,7 +170,7 @@ necessary (as it its purpose). library(dplyr) # Reference time points for which we want to compute slide values: -versions <- seq(as.Date("2020-06-01"), +versions <- seq(as.Date("2020-06-02"), as.Date("2020-06-15"), by = "1 day" ) @@ -219,7 +219,7 @@ archive_cases_dv_subset \%>\% .versions = versions ) \%>\% ungroup() \%>\% - arrange(geo_value, time_value) + arrange(geo_value, version) # --- Advanced: --- diff --git a/vignettes/archive.Rmd b/vignettes/archive.Rmd index 38707d7a6..62eea2aa5 100644 --- a/vignettes/archive.Rmd +++ b/vignettes/archive.Rmd @@ -76,7 +76,7 @@ format, with `issue` playing the role of `version`. We can now use redundant version updates in `as_epi_archive` using compactify, please refer to the [compactify vignette](articles/compactify.html). -```{r, eval=FALSE} +```{r} x <- dv %>% select(geo_value, time_value, version = issue, percent_cli = value) %>% as_epi_archive(compactify = TRUE)