library(recipes)
# 2 predictors
dat <- data.frame(
x1 = 1:10,
x2 = 11:20,
y = 1:10
)
rec <- recipe(y ~ ., data = dat) %>%
step_collapse(x1, x2, new_col = "pred") %>%
prep()
bake(rec, new_data = NULL)
Run the code above in your browser using DataLab