Skip to content

Commit 749ce4e

Browse files
committed
add explanation for handling additional keys
1 parent c4c8fc5 commit 749ce4e

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

R/epi_df.R

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,9 @@ NULL
105105
#' then the current day-time will be used.
106106
#' @param additional_metadata List of additional metadata to attach to the
107107
#' `epi_df` object. The metadata will have `geo_type`, `time_type`, and
108-
#' `as_of` fields; named entries from the passed list or will be included as
109-
#' well.
108+
#' `as_of` fields; named entries from the passed list will be included as
109+
#' well. If your tibble has additional keys, be sure to specify them
110+
#' in the `other_keys` component of `additional_metadata`.
110111
#' @param ... Additional arguments passed to methods.
111112
#' @return An `epi_df` object.
112113
#'
@@ -188,8 +189,9 @@ new_epi_df = function(x = tibble::tibble(), geo_type, time_type, as_of,
188189
#' then the current day-time will be used.
189190
#' @param additional_metadata List of additional metadata to attach to the
190191
#' `epi_df` object. The metadata will have `geo_type`, `time_type`, and
191-
#' `as_of` fields; named entries from the passed list or will be included as
192-
#' well.
192+
#' `as_of` fields; named entries from the passed list will be included as
193+
#' well. If your tibble has additional keys, be sure to specify them
194+
#' in the `other_keys` component of `additional_metadata`.
193195
#' @param ... Additional arguments passed to methods.
194196
#' @return An `epi_df` object.
195197
#'
@@ -248,9 +250,12 @@ new_epi_df = function(x = tibble::tibble(), geo_type, time_type, as_of,
248250
#'
249251
#' ex3 <- ex3_input %>%
250252
#' tsibble::as_tsibble() %>% # needed to add the additional metadata
253+
#' # add 2 extra keys
251254
#' dplyr::mutate(
252255
#' state = rep("MA",6),
253-
#' pol = rep(c("blue", "swing", "swing"), each = 2)) %>% # 2 extra keys
256+
#' pol = rep(c("blue", "swing", "swing"), each = 2)) %>%
257+
#' # the 2 extra keys we added have to be specified in the other_keys
258+
#' # component of additional_metadata.
254259
#' as_epi_df(additional_metadata = list(other_keys = c("state", "pol")))
255260
#'
256261
#' attr(ex3,"metadata")

man/as_epi_df.Rd

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

man/new_epi_df.Rd

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

0 commit comments

Comments
 (0)