Skip to content

Commit

Permalink
Merge pull request #1070 from DavisVaughan/fix/dev-dplyr
Browse files Browse the repository at this point in the history
Fixes for dev dplyr
  • Loading branch information
EmilHvitfeldt authored Dec 15, 2022
2 parents d27d07b + 7d273d1 commit 9e4d0f3
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 13 deletions.
5 changes: 5 additions & 0 deletions R/misc.R
Original file line number Diff line number Diff line change
Expand Up @@ -861,3 +861,8 @@ recipes_error_context <- function(expr, step_name) {
}
)
}

vec_paste0 <- function(..., collapse = NULL) {
args <- vctrs::vec_recycle_common(...)
rlang::inject(paste0(!!!args, collapse = collapse))
}
2 changes: 1 addition & 1 deletion R/naindicate.R
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ bake.step_indicate_na <- function(object, new_data, ...) {
)

cols <- tibble::new_tibble(cols, nrow = nrow(new_data))
cols <- dplyr::rename_with(cols, ~ paste0(object$prefix, "_", .x))
cols <- dplyr::rename_with(cols, ~ vec_paste0(object$prefix, "_", .x))

new_data <- dplyr::bind_cols(new_data, cols)
new_data
Expand Down
4 changes: 3 additions & 1 deletion R/naomit.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ prep.step_naomit <- function(x, training, info = NULL, ...) {

#' @export
bake.step_naomit <- function(object, new_data, ...) {
tibble::as_tibble(tidyr::drop_na(new_data, object$columns))
columns <- object$columns
columns <- unname(columns)
tibble::as_tibble(tidyr::drop_na(new_data, tidyselect::all_of(columns)))
}

print.step_naomit <-
Expand Down
11 changes: 0 additions & 11 deletions tests/testthat/test_slice.R
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,6 @@ test_that("quasiquotation", {
expect_equal(dplyr_train, rec_2_train)
})


test_that("no input", {
no_inputs <-
iris_rec %>%
step_slice() %>%
prep(training = iris) %>%
bake(new_data = NULL, composition = "data.frame")
expect_equal(no_inputs, iris)
})


test_that("printing", {
rec <- iris_rec %>% step_slice(1:2)
expect_snapshot(print(rec))
Expand Down

0 comments on commit 9e4d0f3

Please sign in to comment.