library(tidymodels)
rec_prep <- recipe(cty ~ ., data = mpg) %>%
step_YeoJohnson(cty) %>%
prep(data = mpg)
yj_estimate <- rec_prep %>%
tidy(1) %>%
pluck("value", 1)
rec_prep %>%
juice() %>%
mutate(cty_original = VGAM::yeo.johnson(cty, lambda = yj_estimate, inverse = TRUE)) %>%
select(contains('cty'))
#> # A tibble: 234 x 2
#> cty cty_original
#> <dbl> <dbl>
#> 1 2.84 18.
#> 2 2.98 21.
#> 3 2.93 20.0
#> 4 2.98 21.
#> 5 2.74 16.0
#> 6 2.84 18.
#> 7 2.84 18.
#> 8 2.84 18.
#> 9 2.74 16.0
#> 10 2.93 20.0
#> # ... with 224 more rows
Created on 2021-04-13 by the reprex package (v1.0.0)