# NOT RUN {
library(recipes)
library(modeldata)
data(Smithsonian)
smith_tr <- Smithsonian[1:15, ]
smith_te <- Smithsonian[16:20, ]
rec <- recipe(~., data = smith_tr)
if (requireNamespace("janitor", quietly = TRUE)) {
rec <- rec %>%
step_clean_levels(name)
rec <- prep(rec, training = smith_tr)
cleaned <- bake(rec, smith_tr)
tidy(rec, number = 1)
# novel levels are replaced with missing
bake(rec, smith_te)
}
# }
Run the code above in your browser using DataLab