Skip to content

Commit ad3cb38

Browse files
committed
export bake, but as a method
1 parent a83dfd7 commit ad3cb38

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ S3method(augment,epi_workflow)
1818
S3method(autoplot,canned_epipred)
1919
S3method(autoplot,epi_workflow)
2020
S3method(bake,check_enough_train_data)
21+
S3method(bake,epi_recipe)
2122
S3method(bake,step_epi_ahead)
2223
S3method(bake,step_epi_lag)
2324
S3method(bake,step_growth_rate)

R/epi_recipe.R

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,28 @@ prep.epi_recipe <- function(
557557
x
558558
}
559559

560+
#' @export
561+
bake.epi_recipe <- function(object, new_data, ..., composition = "epi_df") {
562+
meta <- NULL
563+
if (composition == "epi_df") {
564+
if (is_epi_df(new_data)) {
565+
meta <- attr(new_data, "metadata")
566+
} else if (is_epi_df(object$template)) {
567+
meta <- attr(object$template, "metadata")
568+
}
569+
composition <- "tibble"
570+
}
571+
new_data <- NextMethod("bake")
572+
if (!is.null(meta)) {
573+
new_data <- as_epi_df(
574+
new_data, meta$geo_type, meta$time_type, meta$as_of,
575+
meta$additional_metadata %||% list()
576+
)
577+
}
578+
new_data
579+
}
580+
581+
560582
kill_levels <- function(x, keys) {
561583
for (i in which(names(x) %in% keys)) x[[i]] <- list(values = NA, ordered = NA)
562584
x

0 commit comments

Comments
 (0)