Skip to content

Commit da60cea

Browse files
author
admin
committed
Update f documentation in epi_slide
1 parent a9697b7 commit da60cea

File tree

3 files changed

+17
-52
lines changed

3 files changed

+17
-52
lines changed

NAMESPACE

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Generated by roxygen2: do not edit by hand
22

3+
S3method("[",epi_df)
34
S3method(arrange,epi_df)
45
S3method(as_epi_df,data.frame)
56
S3method(as_epi_df,epi_df)
@@ -79,5 +80,3 @@ importFrom(tidyr,unnest)
7980
importFrom(tidyselect,eval_select)
8081
importFrom(tidyselect,starts_with)
8182
importFrom(tsibble,as_tsibble)
82-
importFrom(utils,head)
83-
importFrom(utils,tail)

R/slide.R

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,14 @@
88
#' @param f Function or formula to slide over variables in `x`. To "slide" means
99
#' to apply a function or formula over a running window of `n` time steps
1010
#' (where one time step is typically one day or one week; see details for more
11-
#' explanation). If a function, `f` must take `x`, a data frame with the same
12-
#' column names as the original object; followed by any number of named
13-
#' arguments; and ending with `...`. If a formula, `f` can operate directly on
14-
#' columns accessed via `.x$var`, as in `~ mean(.x$var)` to compute a mean of
15-
#' a column `var` over a sliding window of `n` time steps.
11+
#' explanation). If a function, `f` should take `x`, an `epi_df` with the same
12+
#' names as the non-grouping columns, followed by `g` to refer to the one row
13+
#' tibble with one column per grouping variable that identifies the group,
14+
#' and any number of named arguments (which will be taken from `...`). If a
15+
#' formula, `f` can operate directly on columns accessed via `.x$var`, as
16+
#' in `~ mean(.x$var)` to compute a mean of a column var over a sliding
17+
#' window of n time steps. As well, `.y` may be used in the formula to refer
18+
#' to the groupings that would be described by `g` if `f` was a function.
1619
#' @param ... Additional arguments to pass to the function or formula specified
1720
#' via `f`. Alternatively, if `f` is missing, then the current argument is
1821
#' interpreted as an expression for tidy evaluation. See details.
@@ -85,26 +88,6 @@
8588
#' inferred from the given expression and overrides any name passed explicitly
8689
#' through the `new_col_name` argument.
8790
#'
88-
#' When `f` is a named function with arguments, if a tibble with an unnamed
89-
#' grouping variable is passed in as the method argument to `f`, include a
90-
#' parameter for the grouping-variable in `function()` just prior to
91-
#' specifying the method to prevent that from being overridden. For example:
92-
#' ```
93-
#' # Construct an tibble with an unnamed grouping variable
94-
#' edf = bind_rows(tibble(geo_value = "ak", time_value = as.Date("2020-01-01")
95-
#' + 1:10, x1=1:10, y=1:10 + rnorm(10L))) %>%
96-
#' as_epi_df()
97-
#'
98-
#' # Now, include a row parameter for the grouping variable in the tibble,
99-
#' # which we denote as g, just prior to method = "qr"
100-
#' # Note that if g was not included below, then the method = "qr" would be
101-
#' # overridden, as described above
102-
#' edf %>%
103-
#' group_by(geo_value) %>%
104-
#' epi_slide(function(x, g, method="qr", ...) tibble(model=list(
105-
#' lm(y ~ x1, x, method=method))), n=7L)
106-
#' ```
107-
#'
10891
#' @importFrom lubridate days weeks
10992
#' @importFrom rlang .data .env !! enquo enquos sym
11093
#' @export

man/epi_slide.Rd

Lines changed: 8 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)