data(covers, package = "modeldata")
rec <- recipe(~description, covers) |>
step_regex(description, pattern = "(rock|stony)", result = "rocks") |>
step_regex(description, pattern = "ratake families")
rec2 <- prep(rec, training = covers)
rec2
with_dummies <- bake(rec2, new_data = covers)
with_dummies
tidy(rec, number = 1)
tidy(rec2, number = 1)
# When more than one variable is selected, the new variables are named
# `{variable}_{result}`
covers$description2 <- rev(covers$description)
recipe(~., covers) |>
step_regex(description, description2, pattern = "rock", result = "rocks") |>
prep() |>
bake(new_data = NULL)
Run the code above in your browser using DataLab