@@ -95,7 +95,7 @@ epi_recipe.epi_df <-
9595 keys <- key_colnames(x ) # we know x is an epi_df
9696
9797 var_info <- tibble(variable = vars )
98- key_roles <- c(" geo_value" , " time_value " , rep(" key" , length(keys ) - 2 ))
98+ key_roles <- c(" geo_value" , rep(" key" , length(keys ) - 2 ), " time_value " )
9999
100100 # # Check and add roles when available
101101 if (! is.null(roles )) {
@@ -499,8 +499,11 @@ prep.epi_recipe <- function(
499499 if (! is_epi_df(training )) {
500500 # tidymodels killed our class
501501 # for now, we only allow step_epi_* to alter the metadata
502- training <- dplyr :: dplyr_reconstruct(
503- as_epi_df(training ), before_template
502+ metadata <- attr(before_template , " metadata" )
503+ training <- as_epi_df(
504+ training ,
505+ as_of = metadata $ as_of ,
506+ other_keys = metadata $ other_keys %|| % character ()
504507 )
505508 }
506509 training <- dplyr :: relocate(training , all_of(key_colnames(training )))
@@ -579,8 +582,7 @@ bake.epi_recipe <- function(object, new_data, ..., composition = "epi_df") {
579582 new_data <- as_epi_df(
580583 new_data ,
581584 as_of = meta $ as_of ,
582- # avoid NULL if meta is from saved older epi_df:
583- additional_metadata = meta $ additional_metadata %|| % list ()
585+ other_keys = meta $ other_keys %|| % character ()
584586 )
585587 }
586588 new_data
0 commit comments