data(Sacramento, package = "modeldata")
rec <- recipe(~ city + zip, data = Sacramento)
make_string <- rec %>%
step_factor2string(city)
make_string <- prep(make_string,
training = Sacramento,
strings_as_factors = FALSE
)
make_string
# note that `city` is a string in recipe output
bake(make_string, new_data = NULL) %>% head()
# ...but remains a factor in the original data
Sacramento %>% head()
Run the code above in your browser using DataLab