Skip to content

Commit 0c2d263

Browse files
committed
update additional keys example in vignette
1 parent a06744e commit 0c2d263

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

vignettes/epiprocess.Rmd

+8-4
Original file line numberDiff line numberDiff line change
@@ -200,17 +200,21 @@ ex3 <- jhu_csse_county_level_subset %>%
200200
attr(ex3,"metadata") # geo_type is county currently
201201
```
202202

203-
Now we add state (MA) as a new column and a key to the metadata. Reminder that lower case state name abbreviations are what we would expect if this were a `geo_value` column.
204-
```{r}
203+
Now we add `state` (MA) and `pol` as new columns to the data and as new keys to the metadata. Reminder that lower case state name abbreviations are what we would expect if this were a `geo_value` column.
205204

205+
```{r}
206206
ex3 <- ex3 %>%
207207
as_tibble() %>% # needed to add the additional metadata
208-
mutate(state = rep(tolower("MA"),6)) %>%
209-
as_epi_df(additional_metadata = list(other_keys = "state"))
208+
mutate(
209+
state = rep(tolower("MA"),6),
210+
pol = rep(c("blue", "swing", "swing"), each = 2)) %>%
211+
as_epi_df(additional_metadata = list(other_keys = c("state", "pol")))
210212
211213
attr(ex3,"metadata")
212214
```
213215

216+
Note that the two additional keys we added, `state` and `pol`, are specified as a character vector in the `other_keys` component of the `additional_metadata` list. They must be specified in this manner so that downstream actions on the `epi_df`, like model fitting and prediction, can recognize and use these keys.
217+
214218
Currently `other_keys` metadata in `epi_df` doesn't impact `epi_slide()`, contrary to `other_keys` in `as_epi_archive` which affects how the update data is interpreted.
215219

216220
## Working with `epi_df` objects downstream

0 commit comments

Comments
 (0)