| step_clean_names | R Documentation |
step_clean_names() creates a specification of a recipe step that will
clean variable names so the names consist only of letters, numbers, and the
underscore.
step_clean_names(
recipe,
...,
role = NA,
trained = FALSE,
clean = NULL,
skip = FALSE,
id = rand_id("clean_names")
)
recipe |
A |
... |
One or more selector functions to choose which variables are
affected by the step. See |
role |
Not used by this step since no new variables are created. |
trained |
A logical to indicate if the quantities for preprocessing have been estimated. |
clean |
A named character vector to clean variable names. This is |
skip |
A logical. Should the step be skipped when the recipe is baked
by |
id |
A character string that is unique to this step to identify it. |
The variable names are cleaned with janitor::make_clean_names(), which is
the function responsible for the cleaning.
An updated version of recipe with the new step added
to the sequence of existing steps (if any).
When you tidy() this step, a tibble is returned with
columns terms, value, and id:
character, the new clean variable names
character, the original variable names
character, id of this step
The underlying operation does not allow for case weights.
step_clean_levels(), recipes::step_factor2string(),
recipes::step_string2factor(), recipes::step_regex(),
recipes::step_unknown(), recipes::step_novel(), recipes::step_other()
Other Steps for Text Cleaning:
step_clean_levels()
library(recipes)
data(airquality)
air_tr <- tibble(airquality[1:100, ])
air_te <- tibble(airquality[101:153, ])
rec <- recipe(~., data = air_tr)
rec <- rec |>
step_clean_names(all_predictors())
rec <- prep(rec, training = air_tr)
tidy(rec, number = 1)
bake(rec, air_tr)
bake(rec, air_te)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.