Skip to content

Commit f272839

Browse files
committed
Committed changes that should be updated.
1 parent d73d9e2 commit f272839

File tree

3 files changed

+37
-12
lines changed

3 files changed

+37
-12
lines changed

R/step_epi_naomit.R

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
1-
#' Special NA omit step that does two steps in one
1+
#' Unified NA omission wrapper function for recipes
22
#'
3-
#' @param x Recipe to be used for omission steps
3+
#' @param recipe Recipe to be used for omission steps
44
#'
5-
#' @return Omits NA's from both predictors and outcomes and training time;
6-
#' however, only omits predictors at prediction time
5+
#' @return Omits NA's from both predictors and outcomes at training time;
6+
#' however, only omits associated predictors at prediction time to avoid
7+
#' losing data.
78
#' @export
9+
#' @examples
10+
#' tibble(geo_value = rep("place",200),
11+
#' time_value = as.Date("2021-01-01") + 0:199,
12+
#' case_rate = 1:200,
13+
#' death_rate = 1:200) %>%
14+
#' as_epi_df() %>%
15+
#' recipe() %>%
16+
#' step_epi_naomit()
817

9-
step_epi_naomit <- function(x) {
10-
x %>%
18+
19+
step_epi_naomit <- function(recipe) {
20+
stopifnot("recipe" %in% class(recipe))
21+
recipe %>%
1122
recipes::step_naomit(all_predictors()) %>%
1223
recipes::step_naomit(all_outcomes(), skip = TRUE)
1324
}

man/step_epi_naomit.Rd

Lines changed: 16 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-step_epi_naomit.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ r <- epi_recipe(x) %>%
1616
step_epi_ahead(death_rate, ahead = 7) %>%
1717
step_epi_lag(death_rate, lag = c(0,7,14))
1818

19+
test_that("Argument must be a recipe", {
20+
expect_error(step_epi_naomit(x))
21+
})
22+
1923
z1 <- step_epi_naomit(r)
2024
z2 <- r %>%
2125
step_naomit(all_predictors()) %>%

0 commit comments

Comments
 (0)