diff --git a/DESCRIPTION b/DESCRIPTION index 00b78130..18a3bdfb 100755 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -56,7 +56,7 @@ Config/testthat/edition: 3 Encoding: UTF-8 LazyData: true Roxygen: list(markdown = TRUE) -RoxygenNote: 7.2.0 +RoxygenNote: 7.2.1 Depends: R (>= 2.10) URL: https://cmu-delphi.github.io/epiprocess/ diff --git a/R/archive.R b/R/archive.R index e81315a7..3cdc22f0 100644 --- a/R/archive.R +++ b/R/archive.R @@ -286,7 +286,7 @@ epi_archive = #' details. #' @importFrom data.table key #' @importFrom rlang !! !!! enquo enquos is_quosure sym syms - slide = function(f, ..., n = 7, group_by, ref_time_values, + slide = function(f, ..., n, group_by, ref_time_values, time_step, new_col_name = "slide_value", as_list_col = FALSE, names_sep = "_", all_rows = FALSE) { diff --git a/R/methods-epi_archive.R b/R/methods-epi_archive.R index 4a1cd375..9a03f5b9 100644 --- a/R/methods-epi_archive.R +++ b/R/methods-epi_archive.R @@ -115,7 +115,7 @@ epix_merge = function(x, y, ..., locf = TRUE, nan = NA) { #' @param n Number of time steps to use in the running window. For example, if #' `n = 7`, and one time step is one day, then to produce a value on January 7 #' we apply the given function or formula to data in between January 1 and -#' 7. Default is 7. +#' 7. #' @param group_by The variable(s) to group by before slide computation. If #' missing, then the keys in the underlying data table, excluding `time_value` #' and `version`, will be used for grouping. To omit a grouping entirely, use @@ -202,7 +202,7 @@ epix_merge = function(x, y, ..., locf = TRUE, nan = NA) { #' group_by = geo_value, #' ref_time_values = time_values, #' new_col_name = 'case_rate_3d_av') -epix_slide = function(x, f, ..., n = 7, group_by, ref_time_values, +epix_slide = function(x, f, ..., n, group_by, ref_time_values, time_step, new_col_name = "slide_value", as_list_col = FALSE, names_sep = "_", all_rows = FALSE) { if (!inherits(x, "epi_archive")) Abort("`x` must be of class `epi_archive`.") diff --git a/R/slide.R b/R/slide.R index 5861353b..283ecd8c 100644 --- a/R/slide.R +++ b/R/slide.R @@ -22,7 +22,7 @@ #' @param n Number of time steps to use in the running window. For example, if #' `n = 7`, one time step is one day, and the alignment is "right", then to #' produce a value on January 7 we apply the given function or formula to data -#' in between January 1 and 7. Default is 7. +#' in between January 1 and 7. #' @param ref_time_values Time values for sliding computations, meaning, each #' element of this vector serves as the reference time point for one sliding #' window. If missing, then this will be set to all unique time values in the @@ -114,7 +114,7 @@ #' epi_slide(a = data.frame(cases_2dav = mean(cases), #' cases_2dma = mad(cases)), #' n = 2, as_list_col = TRUE) -epi_slide = function(x, f, ..., n = 7, ref_time_values, +epi_slide = function(x, f, ..., n, ref_time_values, align = c("right", "center", "left"), before, time_step, new_col_name = "slide_value", as_list_col = FALSE, names_sep = "_", all_rows = FALSE) { diff --git a/man/as_epi_df.Rd b/man/as_epi_df.Rd index 5d1b1335..b5df1302 100644 --- a/man/as_epi_df.Rd +++ b/man/as_epi_df.Rd @@ -51,9 +51,9 @@ examples. } \section{Methods (by class)}{ \itemize{ -\item \code{epi_df}: Simply returns the \code{epi_df} object unchanged. +\item \code{as_epi_df(epi_df)}: Simply returns the \code{epi_df} object unchanged. -\item \code{tbl_df}: The input tibble \code{x} must contain the columns +\item \code{as_epi_df(tbl_df)}: The input tibble \code{x} must contain the columns \code{geo_value} and \code{time_value}. All other columns will be preserved as is, and treated as measured variables. If \code{as_of} is missing, then the function will try to guess it from an \code{as_of}, \code{issue}, or \code{version} column of \code{x} @@ -61,14 +61,14 @@ will try to guess it from an \code{as_of}, \code{issue}, or \code{version} colum (stored in its attributes); if this fails, then the current day-time will be used. -\item \code{data.frame}: Works analogously to \code{as_epi_df.tbl_df()}. +\item \code{as_epi_df(data.frame)}: Works analogously to \code{as_epi_df.tbl_df()}. -\item \code{tbl_ts}: Works analogously to \code{as_epi_df.tbl_df()}, except that +\item \code{as_epi_df(tbl_ts)}: Works analogously to \code{as_epi_df.tbl_df()}, except that the \code{tbl_ts} class is dropped, and any key variables (other than "geo_value") are added to the metadata of the returned object, under the \code{other_keys} field. -}} +}} \examples{ # Convert a `tsibble` that has county code as an extra key # Notice that county code should be a character string to preserve any leading zeroes diff --git a/man/epi_archive.Rd b/man/epi_archive.Rd index 84ac9406..93a33dd5 100644 --- a/man/epi_archive.Rd +++ b/man/epi_archive.Rd @@ -193,7 +193,7 @@ details. \if{html}{\out{
}}\preformatted{epi_archive$slide( f, ..., - n = 7, + n, group_by, ref_time_values, time_step, diff --git a/man/epi_slide.Rd b/man/epi_slide.Rd index 9c8c2102..1b620b69 100644 --- a/man/epi_slide.Rd +++ b/man/epi_slide.Rd @@ -8,7 +8,7 @@ epi_slide( x, f, ..., - n = 7, + n, ref_time_values, align = c("right", "center", "left"), before, @@ -41,7 +41,7 @@ interpreted as an expression for tidy evaluation. See details.} \item{n}{Number of time steps to use in the running window. For example, if \code{n = 7}, one time step is one day, and the alignment is "right", then to produce a value on January 7 we apply the given function or formula to data -in between January 1 and 7. Default is 7.} +in between January 1 and 7.} \item{ref_time_values}{Time values for sliding computations, meaning, each element of this vector serves as the reference time point for one sliding diff --git a/man/epix_slide.Rd b/man/epix_slide.Rd index 19da4f06..79e9c1c3 100644 --- a/man/epix_slide.Rd +++ b/man/epix_slide.Rd @@ -8,7 +8,7 @@ epix_slide( x, f, ..., - n = 7, + n, group_by, ref_time_values, time_step, @@ -37,7 +37,7 @@ interpreted as an expression for tidy evaluation.} \item{n}{Number of time steps to use in the running window. For example, if \code{n = 7}, and one time step is one day, then to produce a value on January 7 we apply the given function or formula to data in between January 1 and -7. Default is 7.} +7.} \item{group_by}{The variable(s) to group by before slide computation. If missing, then the keys in the underlying data table, excluding \code{time_value}