1library(testthat) 2library(recipes) 3library(tibble) 4 5n <- 20 6ex_dat <- data.frame(x1 = seq(0, 1, length = n), 7 x2 = rep(1:5, 4)) 8 9test_that('simple sqrt trans', { 10 11 rec <- recipe(~., data = ex_dat) %>% 12 step_sqrt(x1, x2) 13 14 rec_trained <- prep(rec, training = ex_dat, verbose = FALSE) 15 rec_trans <- bake(rec_trained, new_data = ex_dat) 16 17 exp_res <- as_tibble(lapply(ex_dat, sqrt)) 18 expect_equal(rec_trans, exp_res) 19 20}) 21 22 23test_that('printing', { 24 rec <- recipe(~., data = ex_dat) %>% 25 step_sqrt(x1, x2) 26 expect_output(print(rec)) 27 expect_output(prep(rec, training = ex_dat, verbose = TRUE)) 28}) 29 30