Skip to content

Commit c3ca17b

Browse files
authored
Merge pull request #333 from cmu-delphi/lcb/v.0.7.0-fixup
Fix up checks/vignettes for v0.7.0
2 parents ff97fda + a2968b7 commit c3ca17b

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

vignettes/epiprocess.Rmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Get started with `epiprocess`
33
output: rmarkdown::html_vignette
44
vignette: >
5-
%\VignetteIndexEntry{Get started with epiprocess}
5+
%\VignetteIndexEntry{Get started with `epiprocess`}
66
%\VignetteEncoding{UTF-8}
77
%\VignetteEngine{knitr::rmarkdown}
88
editor_options:

vignettes/slide.Rmd

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,20 +92,35 @@ x <- x %>%
9292
head(x, 10)
9393
```
9494

95+
Some other information is available in additional variables:
96+
97+
* `.group_key` is a one-row tibble containing the values of the grouping
98+
variables for the associated group
99+
* `.ref_time_value` is the reference time value the time window was based on
100+
101+
Like in `group_modify()`, there are alternative names for these variables as
102+
well: `.` can be used instead of `.x`, `.y` instead of `.group_key`, and `.z`
103+
instead of `.ref_time_value`.
104+
95105
## Slide with a function
96106

97107
We can also pass a function for the first argument in `epi_slide()`. In this
98-
case, the passed function must accept the following arguments: `x`, a data frame
99-
with the non-grouping columns of the original object, containing the time window
100-
data for one `ref_time_value`-group combination; followed by `g`, a one-row
101-
tibble containing the values of the grouping variables for the associated group;
102-
followed by any number of named arguments. Recreating the last example of a
103-
7-day trailing average:
108+
case, the passed function must accept the following arguments:
109+
110+
In this case, the passed function `f` must accept the following arguments: a
111+
data frame with the same column names as the original object, minus any grouping
112+
variables, containing the time window data for one group-`ref_time_value`
113+
combination; followed by a one-row tibble containing the values of the grouping
114+
variables for the associated group; followed by the associated `ref_time_value`.
115+
It can accept additional arguments; `epi_slide()` will forward any `...` args it
116+
receives to `f`.
117+
118+
Recreating the last example of a 7-day trailing average:
104119

105120
```{r}
106121
x <- x %>%
107122
group_by(geo_value) %>%
108-
epi_slide(function(x, g) mean(x$cases), before = 6, new_col_name = "cases_7dav") %>%
123+
epi_slide(function(x, gk, rtv) mean(x$cases), before = 6, new_col_name = "cases_7dav") %>%
109124
ungroup()
110125
111126
head(x, 10)
@@ -127,6 +142,8 @@ x <- x %>%
127142
128143
head(x, 10)
129144
```
145+
In addition to referring to individual columns by name, you can refer to the
146+
time window data as an `epi_df` or `tibble` using `.x`. Similarly, the other arguments of the function format are available through the magic names `.group_key` and `.ref_time_value`, and the tidyverse "pronouns" `.data` and `.env` can also be used.
130147

131148
As a simple sanity check, we visualize the 7-day trailing averages computed on
132149
top of the original counts:

0 commit comments

Comments
 (0)