|
84 | 84 | #' tidy evaluation (first example, above), then the name for the new column is
|
85 | 85 | #' inferred from the given expression and overrides any name passed explicitly
|
86 | 86 | #' 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 | +#' |
88 | 108 | #' @importFrom lubridate days weeks
|
89 | 109 | #' @importFrom rlang .data .env !! enquo enquos sym
|
90 | 110 | #' @export
|
|
0 commit comments