Skip to content

Commit

Permalink
only adding metadata if given an epi_df originally
Browse files Browse the repository at this point in the history
  • Loading branch information
dsweber2 committed Sep 30, 2024
1 parent a0f3c27 commit 09fd4a9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@
^doc$
^Meta$
^.lintr$
^.venv$
^.venv$
^inst/templates$
13 changes: 9 additions & 4 deletions R/epi_shift.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,14 @@ add_shifted_columns <- function(new_data, object) {
processed <- new_data %>%
full_join(shifted, by = ok) %>%
group_by(across(all_of(kill_time_value(ok)))) %>%
arrange(time_value) %>%
ungroup() %>%
as_epi_df()
attributes(processed)$metadata <- attributes(new_data)$metadata
arrange(time_value)
if (inherits(new_data, "epi_df")) {
processed <- processed %>%
ungroup() %>%
as_epi_df(
as_of = attributes(new_data)$metadata$as_of,
other_keys = attributes(new_data)$metadata$other_keys
)
}
return(processed)
}
2 changes: 0 additions & 2 deletions R/step_epi_shift.R
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,6 @@ prep.step_epi_ahead <- function(x, training, info = NULL, ...) {

#' @export
bake.step_epi_lag <- function(object, new_data, ...) {
names(object)
object$shift_grid
add_shifted_columns(new_data, object)
}

Expand Down

0 comments on commit 09fd4a9

Please sign in to comment.