# NOT RUN {
library(parsnip)
library(recipes)
library(magrittr)
model <- linear_reg() %>%
set_engine("lm")
wf_unfit <- workflow() %>%
add_model(model) %>%
add_formula(mpg ~ cyl + log(disp))
wf_fit_pre <- .fit_pre(wf_unfit, mtcars)
wf_fit_model <- .fit_model(wf_fit_pre, control_workflow())
wf_fit <- .fit_finalize(wf_fit_model)
# Notice that fitting through the model doesn't mark the
# workflow as being "trained"
wf_fit_model
# Finalizing the workflow marks it as "trained"
wf_fit
# Which allows you to predict from it
try(predict(wf_fit_model, mtcars))
predict(wf_fit, mtcars)
# }
Run the code above in your browser using DataLab