data(Sacramento, package = "modeldata")
rec <- recipe(~ city + zip, data = Sacramento) %>%
step_unknown(city, new_level = "UNKNOWN") %>%
step_relevel(city, ref_level = "UNKNOWN") %>%
prep()
data <- bake(rec, Sacramento)
levels(data$city)
Run the code above in your browser using DataLab