Skip to content

Commit

Permalink
fix epi_slide_mean examples
Browse files Browse the repository at this point in the history
Can't use column names like vars
  • Loading branch information
nmdefries committed Jan 30, 2024
1 parent 6fd21ee commit 58b8163
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
16 changes: 12 additions & 4 deletions R/slide.R
Original file line number Diff line number Diff line change
Expand Up @@ -477,28 +477,36 @@ epi_slide <- function(x, f, ..., before, after, ref_time_values,
#' # slide a 7-day trailing average formula on cases
#' jhu_csse_daily_subset %>%
#' group_by(geo_value) %>%
#' epi_slide_mean(cases, new_col_name = cases_7dav, names_sep = NULL, before = 6) %>%
#' epi_slide_mean("cases", new_col_name = "cases_7dav", names_sep = NULL, before = 6) %>%
#' # rmv a nonessential var. to ensure new col is printed
#' dplyr::select(-death_rate_7d_av)
#'
#' # slide a 7-day trailing average formula on cases. Adjust `frollmean` settings for speed
#' # and accuracy, and to allow partially-missing windows.
#' jhu_csse_daily_subset %>%
#' group_by(geo_value) %>%
#' epi_slide_mean("cases", new_col_name = "cases_7dav", names_sep = NULL, before = 6,
#' na.rm = TRUE, algo = "exact", hasNA = TRUE) %>%
#' dplyr::select(-death_rate_7d_av)
#'
#' # slide a 7-day leading average
#' jhu_csse_daily_subset %>%
#' group_by(geo_value) %>%
#' epi_slide_mean(cases, new_col_name = cases_7dav, names_sep = NULL, after = 6) %>%
#' epi_slide_mean("cases", new_col_name = "cases_7dav", names_sep = NULL, after = 6) %>%
#' # rmv a nonessential var. to ensure new col is printed
#' dplyr::select(-death_rate_7d_av)
#'
#' # slide a 7-day centre-aligned average
#' jhu_csse_daily_subset %>%
#' group_by(geo_value) %>%
#' epi_slide_mean(cases, new_col_name = cases_7dav, names_sep = NULL, before = 3, after = 3) %>%
#' epi_slide_mean("cases", new_col_name = "cases_7dav", names_sep = NULL, before = 3, after = 3) %>%
#' # rmv a nonessential var. to ensure new col is printed
#' dplyr::select(-death_rate_7d_av)
#'
#' # slide a 14-day centre-aligned average
#' jhu_csse_daily_subset %>%
#' group_by(geo_value) %>%
#' epi_slide_mean(cases, new_col_name = cases_7dav, names_sep = NULL, before = 6, after = 7) %>%
#' epi_slide_mean("cases", new_col_name = "cases_7dav", names_sep = NULL, before = 6, after = 7) %>%
#' # rmv a nonessential var. to ensure new col is printed
#' dplyr::select(-death_rate_7d_av)
epi_slide_mean = function(x, col_name, ..., before, after, ref_time_values,
Expand Down
16 changes: 12 additions & 4 deletions man/epi_slide_mean.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 58b8163

Please sign in to comment.