Skip to content

Commit d16d889

Browse files
authored
Merge pull request #9 from dajmcdon/epi_slide-f-param-doc
epi_slide `f` parameter documentation
2 parents 6f31970 + cccfea9 commit d16d889

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

R/slide.R

+21-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,27 @@
8484
#' tidy evaluation (first example, above), then the name for the new column is
8585
#' inferred from the given expression and overrides any name passed explicitly
8686
#' through the `new_col_name` argument.
87-
#'
87+
#'
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+
#'
88108
#' @importFrom lubridate days weeks
89109
#' @importFrom rlang .data .env !! enquo enquos sym
90110
#' @export

man/epi_slide.Rd

+18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)