# NOT RUN {
library(parsnip)
library(recipes)
library(magrittr)
training <- mtcars[1:20,]
testing <- mtcars[21:32,]
model <- linear_reg() %>%
set_engine("lm")
workflow <- workflow() %>%
add_model(model)
recipe <- recipe(mpg ~ cyl + disp, training) %>%
step_log(disp)
workflow <- add_recipe(workflow, recipe)
fit_workflow <- fit(workflow, training)
# This will automatically `bake()` the recipe on `testing`,
# applying the log step to `disp`, and then fit the regression.
predict(fit_workflow, testing)
# }
Run the code above in your browser using DataLab