From aae9dee3becd26dc59da73ed2c157eb4ba95240f Mon Sep 17 00:00:00 2001 From: Nat DeFries <42820733+nmdefries@users.noreply.github.com> Date: Thu, 18 Jan 2024 11:27:23 -0500 Subject: [PATCH] document --- man/as_epi_archive.Rd | 56 ++++++++++++++++++++------------- man/as_epi_df.Rd | 44 +++++++++++++++----------- man/detect_outlr.Rd | 62 +++++++++++++++++++++++-------------- man/detect_outlr_rm.Rd | 7 +++-- man/detect_outlr_stl.Rd | 7 +++-- man/epi_archive.Rd | 18 ++++++----- man/epi_cor.Rd | 48 ++++++++++++++++------------ man/epi_slide.Rd | 22 +++++++------ man/epix_as_of.Rd | 25 ++++++++++----- man/epix_merge.Rd | 10 +++--- man/epix_slide.Rd | 55 +++++++++++++++++--------------- man/group_by.epi_archive.Rd | 48 ++++++++++++++++------------ man/growth_rate.Rd | 12 +++---- man/is_epi_archive.Rd | 4 +-- 14 files changed, 247 insertions(+), 171 deletions(-) diff --git a/man/as_epi_archive.Rd b/man/as_epi_archive.Rd index d63a5faa..a1c60687 100644 --- a/man/as_epi_archive.Rd +++ b/man/as_epi_archive.Rd @@ -99,32 +99,44 @@ would be equivalent to: # Simple ex. with necessary keys tib <- tibble::tibble( geo_value = rep(c("ca", "hi"), each = 5), - time_value = rep(seq(as.Date("2020-01-01"), - by = 1, length.out = 5), times = 2), - version = rep(seq(as.Date("2020-01-02"), - by = 1, length.out = 5), times = 2), + time_value = rep(seq(as.Date("2020-01-01"), + by = 1, length.out = 5 + ), times = 2), + version = rep(seq(as.Date("2020-01-02"), + by = 1, length.out = 5 + ), times = 2), value = rnorm(10, mean = 2, sd = 1) ) -toy_epi_archive <- tib \%>\% as_epi_archive(geo_type = "state", - time_type = "day") -toy_epi_archive +toy_epi_archive <- tib \%>\% as_epi_archive( + geo_type = "state", + time_type = "day" +) +toy_epi_archive # Ex. with an additional key for county -df <- data.frame (geo_value = c(replicate(2, "ca"), replicate(2, "fl")), - county = c(1, 3, 2, 5), - time_value = c("2020-06-01", - "2020-06-02", - "2020-06-01", - "2020-06-02"), - version = c("2020-06-02", - "2020-06-03", - "2020-06-02", - "2020-06-03"), - cases = c(1, 2, 3, 4), - cases_rate = c(0.01, 0.02, 0.01, 0.05)) +df <- data.frame( + geo_value = c(replicate(2, "ca"), replicate(2, "fl")), + county = c(1, 3, 2, 5), + time_value = c( + "2020-06-01", + "2020-06-02", + "2020-06-01", + "2020-06-02" + ), + version = c( + "2020-06-02", + "2020-06-03", + "2020-06-02", + "2020-06-03" + ), + cases = c(1, 2, 3, 4), + cases_rate = c(0.01, 0.02, 0.01, 0.05) +) -x <- df \%>\% as_epi_archive(geo_type = "state", - time_type = "day", - other_keys = "county") +x <- df \%>\% as_epi_archive( + geo_type = "state", + time_type = "day", + other_keys = "county" +) } diff --git a/man/as_epi_df.Rd b/man/as_epi_df.Rd index 851aed7e..40c0a1c5 100644 --- a/man/as_epi_df.Rd +++ b/man/as_epi_df.Rd @@ -76,19 +76,22 @@ the \code{tbl_ts} class is dropped, and any key variables (other than ex1_input <- tibble::tibble( geo_value = rep(c("ca", "fl", "pa"), each = 3), - county_code = c("06059","06061","06067", - "12111","12113","12117", - "42101", "42103","42105"), + county_code = c( + "06059", "06061", "06067", + "12111", "12113", "12117", + "42101", "42103", "42105" + ), time_value = rep(seq(as.Date("2020-06-01"), as.Date("2020-06-03"), - by = "day"), length.out = length(geo_value)), + by = "day" + ), length.out = length(geo_value)), value = 1:length(geo_value) + 0.01 * rnorm(length(geo_value)) -) \%>\% +) \%>\% tsibble::as_tsibble(index = time_value, key = c(geo_value, county_code)) # The `other_keys` metadata (`"county_code"` in this case) is automatically # inferred from the `tsibble`'s `key`: ex1 <- as_epi_df(x = ex1_input, geo_type = "state", time_type = "day", as_of = "2020-06-03") -attr(ex1,"metadata")[["other_keys"]] +attr(ex1, "metadata")[["other_keys"]] @@ -102,17 +105,21 @@ ex2_input <- tibble::tibble( state = rep(c("ca", "fl", "pa"), each = 3), # misnamed pol = rep(c("blue", "swing", "swing"), each = 3), # extra key reported_date = rep(seq(as.Date("2020-06-01"), as.Date("2020-06-03"), - by = "day"), length.out = length(state)), # misnamed + by = "day" + ), length.out = length(state)), # misnamed value = 1:length(state) + 0.01 * rnorm(length(state)) -) +) print(ex2_input) -ex2 <- ex2_input \%>\% dplyr::rename(geo_value = state, time_value = reported_date) \%>\% - as_epi_df(geo_type = "state", as_of = "2020-06-03", - additional_metadata = list(other_keys = "pol")) +ex2 <- ex2_input \%>\% + dplyr::rename(geo_value = state, time_value = reported_date) \%>\% + as_epi_df( + geo_type = "state", as_of = "2020-06-03", + additional_metadata = list(other_keys = "pol") + ) -attr(ex2,"metadata") +attr(ex2, "metadata") @@ -120,17 +127,18 @@ attr(ex2,"metadata") ex3_input <- jhu_csse_county_level_subset \%>\% dplyr::filter(time_value > "2021-12-01", state_name == "Massachusetts") \%>\% - dplyr::slice_tail(n = 6) + dplyr::slice_tail(n = 6) -ex3 <- ex3_input \%>\% +ex3 <- ex3_input \%>\% tsibble::as_tsibble() \%>\% # needed to add the additional metadata # add 2 extra keys dplyr::mutate( - state = rep("MA",6), - pol = rep(c("blue", "swing", "swing"), each = 2)) \%>\% - # the 2 extra keys we added have to be specified in the other_keys + state = rep("MA", 6), + pol = rep(c("blue", "swing", "swing"), each = 2) + ) \%>\% + # the 2 extra keys we added have to be specified in the other_keys # component of additional_metadata. as_epi_df(additional_metadata = list(other_keys = c("state", "pol"))) -attr(ex3,"metadata") +attr(ex3, "metadata") } diff --git a/man/detect_outlr.Rd b/man/detect_outlr.Rd index 4aa0b79c..3a793ebf 100644 --- a/man/detect_outlr.Rd +++ b/man/detect_outlr.Rd @@ -64,29 +64,43 @@ For convenience, the outlier detection method can be specified (in the STL decomposition. } \examples{ - detection_methods = dplyr::bind_rows( - dplyr::tibble(method = "rm", - args = list(list(detect_negatives = TRUE, - detection_multiplier = 2.5)), - abbr = "rm"), - dplyr::tibble(method = "stl", - args = list(list(detect_negatives = TRUE, - detection_multiplier = 2.5, - seasonal_period = 7)), - abbr = "stl_seasonal"), - dplyr::tibble(method = "stl", - args = list(list(detect_negatives = TRUE, - detection_multiplier = 2.5, - seasonal_period = NULL)), - abbr = "stl_nonseasonal")) +detection_methods <- dplyr::bind_rows( + dplyr::tibble( + method = "rm", + args = list(list( + detect_negatives = TRUE, + detection_multiplier = 2.5 + )), + abbr = "rm" + ), + dplyr::tibble( + method = "stl", + args = list(list( + detect_negatives = TRUE, + detection_multiplier = 2.5, + seasonal_period = 7 + )), + abbr = "stl_seasonal" + ), + dplyr::tibble( + method = "stl", + args = list(list( + detect_negatives = TRUE, + detection_multiplier = 2.5, + seasonal_period = NULL + )), + abbr = "stl_nonseasonal" + ) +) - x <- incidence_num_outlier_example \%>\% - dplyr::select(geo_value,time_value,cases) \%>\% - as_epi_df() \%>\% - group_by(geo_value) \%>\% - mutate(outlier_info = detect_outlr( - x = time_value, y = cases, - methods = detection_methods, - combiner = "median")) \%>\% - unnest(outlier_info) +x <- incidence_num_outlier_example \%>\% + dplyr::select(geo_value, time_value, cases) \%>\% + as_epi_df() \%>\% + group_by(geo_value) \%>\% + mutate(outlier_info = detect_outlr( + x = time_value, y = cases, + methods = detection_methods, + combiner = "median" + )) \%>\% + unnest(outlier_info) } diff --git a/man/detect_outlr_rm.Rd b/man/detect_outlr_rm.Rd index 3efae55d..0d011619 100644 --- a/man/detect_outlr_rm.Rd +++ b/man/detect_outlr_rm.Rd @@ -59,10 +59,11 @@ terms of multiples of the rolling interquartile range (IQR). \examples{ # Detect outliers based on a rolling median incidence_num_outlier_example \%>\% - dplyr::select(geo_value,time_value,cases) \%>\% + dplyr::select(geo_value, time_value, cases) \%>\% as_epi_df() \%>\% group_by(geo_value) \%>\% - mutate(outlier_info = detect_outlr_rm( - x = time_value, y = cases)) \%>\% + 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 7e724a4e..34a550d5 100644 --- a/man/detect_outlr_stl.Rd +++ b/man/detect_outlr_stl.Rd @@ -78,11 +78,12 @@ are exactly as in \code{detect_outlr_rm()}. \examples{ # Detects outliers based on a seasonal-trend decomposition using LOESS incidence_num_outlier_example \%>\% - dplyr::select(geo_value,time_value,cases) \%>\% + dplyr::select(geo_value, time_value, cases) \%>\% as_epi_df() \%>\% group_by(geo_value) \%>\% - mutate(outlier_info = detect_outlr_stl( + mutate(outlier_info = detect_outlr_stl( x = time_value, y = cases, - seasonal_period = 7 )) \%>\% # weekly seasonality for daily data + seasonal_period = 7 + )) \%>\% # weekly seasonality for daily data unnest(outlier_info) } diff --git a/man/epi_archive.Rd b/man/epi_archive.Rd index a4a58645..366eafe0 100644 --- a/man/epi_archive.Rd +++ b/man/epi_archive.Rd @@ -100,16 +100,20 @@ are documented in the wrapper function \code{\link[=epix_slide]{epix_slide()}}. \examples{ tib <- tibble::tibble( geo_value = rep(c("ca", "hi"), each = 5), - time_value = rep(seq(as.Date("2020-01-01"), - by = 1, length.out = 5), times = 2), - version = rep(seq(as.Date("2020-01-02"), - by = 1, length.out = 5), times = 2), + time_value = rep(seq(as.Date("2020-01-01"), + by = 1, length.out = 5 + ), times = 2), + version = rep(seq(as.Date("2020-01-02"), + by = 1, length.out = 5 + ), times = 2), value = rnorm(10, mean = 2, sd = 1) ) -toy_epi_archive <- tib \%>\% epi_archive$new(geo_type = "state", - time_type = "day") -toy_epi_archive +toy_epi_archive <- tib \%>\% epi_archive$new( + geo_type = "state", + time_type = "day" +) +toy_epi_archive } \section{Methods}{ \subsection{Public methods}{ diff --git a/man/epi_cor.Rd b/man/epi_cor.Rd index 6b2279db..fb56073f 100644 --- a/man/epi_cor.Rd +++ b/man/epi_cor.Rd @@ -58,30 +58,38 @@ grouping by geo value, time value, or any other variables. See the for examples. } \examples{ - + # linear association of case and death rates on any given day -epi_cor(x = jhu_csse_daily_subset, - var1 = case_rate_7d_av, - var2 = death_rate_7d_av, - cor_by = "time_value") +epi_cor( + x = jhu_csse_daily_subset, + var1 = case_rate_7d_av, + var2 = death_rate_7d_av, + cor_by = "time_value" +) # correlation of death rates and lagged case rates -epi_cor(x = jhu_csse_daily_subset, - var1 = case_rate_7d_av, - var2 = death_rate_7d_av, - cor_by = time_value, - dt1 = -2) +epi_cor( + x = jhu_csse_daily_subset, + var1 = case_rate_7d_av, + var2 = death_rate_7d_av, + cor_by = time_value, + dt1 = -2 +) -# correlation grouped by location -epi_cor(x = jhu_csse_daily_subset, - var1 = case_rate_7d_av, - var2 = death_rate_7d_av, - cor_by = geo_value) +# correlation grouped by location +epi_cor( + x = jhu_csse_daily_subset, + var1 = case_rate_7d_av, + var2 = death_rate_7d_av, + cor_by = geo_value +) # correlation grouped by location and incorporates lagged cases rates -epi_cor(x = jhu_csse_daily_subset, - var1 = case_rate_7d_av, - var2 = death_rate_7d_av, - cor_by = geo_value, - dt1 = -2) +epi_cor( + x = jhu_csse_daily_subset, + var1 = case_rate_7d_av, + var2 = death_rate_7d_av, + cor_by = geo_value, + dt1 = -2 +) } diff --git a/man/epi_slide.Rd b/man/epi_slide.Rd index 33c3a7fb..668be9ff 100644 --- a/man/epi_slide.Rd +++ b/man/epi_slide.Rd @@ -156,9 +156,9 @@ through the \code{new_col_name} argument. # slide a 7-day trailing average formula on cases jhu_csse_daily_subset \%>\% group_by(geo_value) \%>\% - epi_slide(cases_7dav = mean(cases), before = 6) \%>\% + epi_slide(cases_7dav = mean(cases), before = 6) \%>\% # rmv a nonessential var. to ensure new col is printed - dplyr::select(-death_rate_7d_av) + dplyr::select(-death_rate_7d_av) # slide a 7-day leading average jhu_csse_daily_subset \%>\% @@ -170,21 +170,25 @@ jhu_csse_daily_subset \%>\% # slide a 7-day centre-aligned average jhu_csse_daily_subset \%>\% group_by(geo_value) \%>\% - epi_slide(cases_7dav = mean(cases), before = 3, after = 3) \%>\% + epi_slide(cases_7dav = mean(cases), before = 3, after = 3) \%>\% # rmv a nonessential var. to ensure new col is printed - dplyr::select(-death_rate_7d_av) + dplyr::select(-death_rate_7d_av) # slide a 14-day centre-aligned average jhu_csse_daily_subset \%>\% group_by(geo_value) \%>\% - epi_slide(cases_7dav = mean(cases), before = 6, after = 7) \%>\% + epi_slide(cases_7dav = mean(cases), before = 6, after = 7) \%>\% # rmv a nonessential var. to ensure new col is printed - dplyr::select(-death_rate_7d_av) + dplyr::select(-death_rate_7d_av) # nested new columns jhu_csse_daily_subset \%>\% group_by(geo_value) \%>\% - epi_slide(a = data.frame(cases_2dav = mean(cases), - cases_2dma = mad(cases)), - before = 1, as_list_col = TRUE) + epi_slide( + a = data.frame( + cases_2dav = mean(cases), + cases_2dma = mad(cases) + ), + before = 1, as_list_col = TRUE + ) } diff --git a/man/epix_as_of.Rd b/man/epix_as_of.Rd index 51884597..9a0a53ce 100644 --- a/man/epix_as_of.Rd +++ b/man/epix_as_of.Rd @@ -55,14 +55,18 @@ in the future. } \examples{ # warning message of data latency shown -epix_as_of(x = archive_cases_dv_subset, - max_version = max(archive_cases_dv_subset$DT$version)) +epix_as_of( + x = archive_cases_dv_subset, + max_version = max(archive_cases_dv_subset$DT$version) +) range(archive_cases_dv_subset$DT$version) # 2020-06-02 -- 2021-12-01 -epix_as_of(x = archive_cases_dv_subset, - max_version = as.Date("2020-06-12")) +epix_as_of( + x = archive_cases_dv_subset, + max_version = as.Date("2020-06-12") +) # When fetching a snapshot as of the latest version with update data in the # archive, a warning is issued by default, as this update data might not yet @@ -72,10 +76,15 @@ epix_as_of(x = archive_cases_dv_subset, # based on database queries, the latest available update might still be # subject to change, but previous versions should be finalized). We can # muffle such warnings with the following pattern: -withCallingHandlers({ - epix_as_of(x = archive_cases_dv_subset, - max_version = max(archive_cases_dv_subset$DT$version)) -}, epiprocess__snapshot_as_of_clobberable_version = function(wrn) invokeRestart("muffleWarning")) +withCallingHandlers( + { + epix_as_of( + x = archive_cases_dv_subset, + max_version = max(archive_cases_dv_subset$DT$version) + ) + }, + epiprocess__snapshot_as_of_clobberable_version = function(wrn) invokeRestart("muffleWarning") +) # Since R 4.0, there is a `globalCallingHandlers` function that can be used # to globally toggle these warnings. diff --git a/man/epix_merge.Rd b/man/epix_merge.Rd index 09f67fa2..53dea071 100644 --- a/man/epix_merge.Rd +++ b/man/epix_merge.Rd @@ -60,13 +60,13 @@ be clobbered in either input archive. \examples{ # create two example epi_archive datasets x <- archive_cases_dv_subset$DT \%>\% - dplyr::select(geo_value,time_value,version,case_rate_7d_av) \%>\% - as_epi_archive(compactify=TRUE) + dplyr::select(geo_value, time_value, version, case_rate_7d_av) \%>\% + as_epi_archive(compactify = TRUE) y <- archive_cases_dv_subset$DT \%>\% - dplyr::select(geo_value,time_value,version,percent_cli) \%>\% - as_epi_archive(compactify=TRUE) + dplyr::select(geo_value, time_value, version, percent_cli) \%>\% + as_epi_archive(compactify = TRUE) # merge results stored in a third object: -xy = epix_merge(x, y) +xy <- epix_merge(x, y) # vs. mutating x to hold the merge result: x$merge(y) diff --git a/man/epix_slide.Rd b/man/epix_slide.Rd index d94460af..3ac55a18 100644 --- a/man/epix_slide.Rd +++ b/man/epix_slide.Rd @@ -193,17 +193,20 @@ library(dplyr) # Reference time points for which we want to compute slide values: ref_time_values <- seq(as.Date("2020-06-01"), - as.Date("2020-06-15"), - by = "1 day") + as.Date("2020-06-15"), + by = "1 day" +) # A simple (but not very useful) example (see the archive vignette for a more # realistic one): archive_cases_dv_subset \%>\% group_by(geo_value) \%>\% - epix_slide(f = ~ mean(.x$case_rate_7d_av), - before = 2, - ref_time_values = ref_time_values, - new_col_name = 'case_rate_7d_av_recent_av') \%>\% + epix_slide( + f = ~ mean(.x$case_rate_7d_av), + before = 2, + ref_time_values = ref_time_values, + new_col_name = "case_rate_7d_av_recent_av" + ) \%>\% ungroup() # We requested time windows that started 2 days before the corresponding time # values. The actual number of `time_value`s in each computation depends on @@ -221,23 +224,24 @@ archive_cases_dv_subset \%>\% # Examining characteristics of the data passed to each computation with # `all_versions=FALSE`. archive_cases_dv_subset \%>\% - group_by(geo_value) \%>\% - epix_slide( - function(x, gk, rtv) { - tibble( - time_range = if(nrow(x) == 0L) { - "0 `time_value`s" - } else { - sprintf("\%s -- \%s", min(x$time_value), max(x$time_value)) - }, - n = nrow(x), - class1 = class(x)[[1L]] - ) - }, - before = 5, all_versions = FALSE, - ref_time_values = ref_time_values, names_sep=NULL) \%>\% - ungroup() \%>\% - arrange(geo_value, time_value) + group_by(geo_value) \%>\% + epix_slide( + function(x, gk, rtv) { + tibble( + time_range = if (nrow(x) == 0L) { + "0 `time_value`s" + } else { + sprintf("\%s -- \%s", min(x$time_value), max(x$time_value)) + }, + n = nrow(x), + class1 = class(x)[[1L]] + ) + }, + before = 5, all_versions = FALSE, + ref_time_values = ref_time_values, names_sep = NULL + ) \%>\% + ungroup() \%>\% + arrange(geo_value, time_value) # --- Advanced: --- @@ -259,7 +263,7 @@ archive_cases_dv_subset \%>\% toString(min(x$DT$version)) }, versions_end = x$versions_end, - time_range = if(nrow(x$DT) == 0L) { + time_range = if (nrow(x$DT) == 0L) { "0 `time_value`s" } else { sprintf("\%s -- \%s", min(x$DT$time_value), max(x$DT$time_value)) @@ -269,7 +273,8 @@ archive_cases_dv_subset \%>\% ) }, before = 5, all_versions = TRUE, - ref_time_values = ref_time_values, names_sep=NULL) \%>\% + ref_time_values = ref_time_values, names_sep = NULL + ) \%>\% ungroup() \%>\% # Focus on one geo_value so we can better see the columns above: filter(geo_value == "ca") \%>\% diff --git a/man/group_by.epi_archive.Rd b/man/group_by.epi_archive.Rd index aee0a07b..5e867bf3 100644 --- a/man/group_by.epi_archive.Rd +++ b/man/group_by.epi_archive.Rd @@ -93,7 +93,7 @@ to \code{group_by_drop_default.default} (but there is a dedicated method for } \examples{ -grouped_archive = archive_cases_dv_subset \%>\% group_by(geo_value) +grouped_archive <- archive_cases_dv_subset \%>\% group_by(geo_value) # `print` for metadata and method listing: grouped_archive \%>\% print() @@ -102,10 +102,12 @@ grouped_archive \%>\% print() archive_cases_dv_subset \%>\% group_by(geo_value) \%>\% - epix_slide(f = ~ mean(.x$case_rate_7d_av), - before = 2, - ref_time_values = as.Date("2020-06-11") + 0:2, - new_col_name = 'case_rate_3d_av') \%>\% + epix_slide( + f = ~ mean(.x$case_rate_7d_av), + before = 2, + ref_time_values = as.Date("2020-06-11") + 0:2, + new_col_name = "case_rate_3d_av" + ) \%>\% ungroup() # ----------------------------------------------------------------- @@ -113,34 +115,42 @@ archive_cases_dv_subset \%>\% # Advanced: some other features of dplyr grouping are implemented: library(dplyr) -toy_archive = +toy_archive <- tribble( - ~geo_value, ~age_group, ~time_value, ~version, ~value, - "us", "adult", "2000-01-01", "2000-01-02", 121, - "us", "pediatric", "2000-01-02", "2000-01-03", 5, # (addition) - "us", "adult", "2000-01-01", "2000-01-03", 125, # (revision) - "us", "adult", "2000-01-02", "2000-01-03", 130 # (addition) + ~geo_value, ~age_group, ~time_value, ~version, ~value, + "us", "adult", "2000-01-01", "2000-01-02", 121, + "us", "pediatric", "2000-01-02", "2000-01-03", 5, # (addition) + "us", "adult", "2000-01-01", "2000-01-03", 125, # (revision) + "us", "adult", "2000-01-02", "2000-01-03", 130 # (addition) + ) \%>\% + mutate( + age_group = ordered(age_group, c("pediatric", "adult")), + time_value = as.Date(time_value), + version = as.Date(version) ) \%>\% - mutate(age_group = ordered(age_group, c("pediatric", "adult")), - time_value = as.Date(time_value), - version = as.Date(version)) \%>\% as_epi_archive(other_keys = "age_group") # The following are equivalent: toy_archive \%>\% group_by(geo_value, age_group) -toy_archive \%>\% group_by(geo_value) \%>\% group_by(age_group, .add=TRUE) -grouping_cols = c("geo_value", "age_group") +toy_archive \%>\% + group_by(geo_value) \%>\% + group_by(age_group, .add = TRUE) +grouping_cols <- c("geo_value", "age_group") toy_archive \%>\% group_by(across(all_of(grouping_cols))) # And these are equivalent: toy_archive \%>\% group_by(geo_value) -toy_archive \%>\% group_by(geo_value, age_group) \%>\% ungroup(age_group) +toy_archive \%>\% + group_by(geo_value, age_group) \%>\% + ungroup(age_group) # To get the grouping variable names as a `list` of `name`s (a.k.a. symbols): -toy_archive \%>\% group_by(geo_value) \%>\% groups() +toy_archive \%>\% + group_by(geo_value) \%>\% + groups() toy_archive \%>\% - group_by(geo_value, age_group, .drop=FALSE) \%>\% + group_by(geo_value, age_group, .drop = FALSE) \%>\% epix_slide(f = ~ sum(.x$value), before = 20) \%>\% ungroup() diff --git a/man/growth_rate.Rd b/man/growth_rate.Rd index 203d5d7d..7a3f1151 100644 --- a/man/growth_rate.Rd +++ b/man/growth_rate.Rd @@ -136,12 +136,12 @@ user. \examples{ # COVID cases growth rate by state using default method relative change -jhu_csse_daily_subset \%>\% - group_by(geo_value) \%>\% - mutate(cases_gr = growth_rate(x = time_value, y = cases)) +jhu_csse_daily_subset \%>\% + group_by(geo_value) \%>\% + mutate(cases_gr = growth_rate(x = time_value, y = cases)) # Log scale, degree 4 polynomial and 6-fold cross validation -jhu_csse_daily_subset \%>\% - group_by(geo_value) \%>\% - mutate(gr_poly = growth_rate( x = time_value, y = cases, log_scale = TRUE, ord = 4, k = 6)) +jhu_csse_daily_subset \%>\% + group_by(geo_value) \%>\% + mutate(gr_poly = growth_rate(x = time_value, y = cases, log_scale = TRUE, ord = 4, k = 6)) } diff --git a/man/is_epi_archive.Rd b/man/is_epi_archive.Rd index 5b133004..2beb3a8c 100644 --- a/man/is_epi_archive.Rd +++ b/man/is_epi_archive.Rd @@ -25,9 +25,9 @@ is_epi_archive(archive_cases_dv_subset) # TRUE # By default, grouped_epi_archives don't count as epi_archives, as they may # support a different set of operations from regular `epi_archives`. This # behavior can be controlled by `grouped_okay`. -grouped_archive = archive_cases_dv_subset$group_by(geo_value) +grouped_archive <- archive_cases_dv_subset$group_by(geo_value) is_epi_archive(grouped_archive) # FALSE -is_epi_archive(grouped_archive, grouped_okay=TRUE) # TRUE +is_epi_archive(grouped_archive, grouped_okay = TRUE) # TRUE } \seealso{