Skip to content

Commit a4ff33d

Browse files
authored
Merge pull request #3 from kenmawer/km-issue_22_unite
Issue #22 of uniting lag and ahead functions.
2 parents 05e688f + 3457ee5 commit a4ff33d

File tree

3 files changed

+4
-167
lines changed

3 files changed

+4
-167
lines changed

R/epi_ahead.R

-163
This file was deleted.

R/epi_lag.R

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616
#'
1717
#' @family row operation steps
1818
#' @export
19-
#' @rdname step_epi_ahead
19+
#' @rdname step_epi_lag
2020
step_epi_lag <-
2121
function(recipe,
2222
...,
2323
role = "predictor",
2424
trained = FALSE,
25-
lag = 1,
25+
lag = 1, # negative for ahead
2626
prefix = "lag_",
2727
default = NA,
2828
keys = epi_keys(recipe),
@@ -117,7 +117,7 @@ bake.step_epi_lag <- function(object, new_data, ...) {
117117
print.step_epi_lag <-
118118
function(x, width = max(20, options()$width - 30), ...) {
119119
## TODO add printing of the lags
120-
title <- "Lagging "
120+
title <- ifelse(x$lag >= 0, "Lagging", "Leading")
121121
recipes::print_step(x$columns, x$terms, x$trained, title, width)
122122
invisible(x)
123123
}

musings/example-recipe.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ xx <- x %>% filter(time_value > "2021-12-01")
3636
# Baseline AR3
3737
r <- epi_recipe(x) %>% # if we add this as a class, maybe we get better
3838
# behaviour downstream?
39-
step_epi_ahead(death_rate, ahead = 7) %>%
39+
step_epi_lag(death_rate, lag = -7) %>%
4040
step_epi_lag(death_rate, lag = c(0, 7, 14)) %>%
4141
step_epi_lag(case_rate, lag = c(0, 7, 14)) %>%
4242
step_naomit(all_predictors()) %>%

0 commit comments

Comments
 (0)