@@ -117,7 +117,11 @@ new_epi_df = function(x = tibble::tibble(), geo_type, time_type, as_of,
117117 if (! is.data.frame(x )) {
118118 Abort(" `x` must be a data frame." )
119119 }
120-
120+
121+ if (! is.list(additional_metadata )) {
122+ Abort(" `additional_metadata` must be a list type." )
123+ }
124+
121125 # If geo type is missing, then try to guess it
122126 if (missing(geo_type )) {
123127 geo_type = guess_geo_type(x $ geo_value )
@@ -230,7 +234,7 @@ new_epi_df = function(x = tibble::tibble(), geo_type, time_type, as_of,
230234# '
231235# ' ex2 <- ex2_input %>% dplyr::rename(geo_value = state, time_value = reported_date) %>%
232236# ' as_epi_df(geo_type = "state", as_of = "2020-06-03",
233- # ' additional_metadata = c (other_keys = "pol"))
237+ # ' additional_metadata = list (other_keys = "pol"))
234238# '
235239# ' attr(ex2,"metadata")
236240# '
@@ -244,8 +248,10 @@ new_epi_df = function(x = tibble::tibble(), geo_type, time_type, as_of,
244248# '
245249# ' ex3 <- ex3_input %>%
246250# ' tsibble::as_tsibble() %>% # needed to add the additional metadata
247- # ' dplyr::mutate(state = rep("MA",6)) %>%
248- # ' as_epi_df(additional_metadata = c(other_keys = "state"))
251+ # ' dplyr::mutate(
252+ # ' state = rep("MA",6),
253+ # ' pol = rep(c("blue", "swing", "swing"), each = 2)) %>% # 2 extra keys
254+ # ' as_epi_df(additional_metadata = list(other_keys = "state", "pol")) %>%
249255# '
250256# ' attr(ex3,"metadata")
251257as_epi_df = function (x , ... ) {
0 commit comments