step_factor2string {recipes} | R Documentation |
step_factor2string
will convert one or more factor
vectors to strings.
step_factor2string(recipe, ..., role = NA, trained = FALSE, columns = FALSE) ## S3 method for class 'step_factor2string' tidy(x, ...)
recipe |
A recipe object. The step will be added to the sequence of operations for this recipe. |
... |
One or more selector functions to choose which
variables will converted to strings 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. |
columns |
A character string of variables that will be
converted. This is |
x |
A |
prep
has an option stringsAsFactors
that
defaults to TRUE
. If this step is used with the default
option, the string(s() produced by this step will be converted
to factors after all of the steps have been prepped.
An updated version of recipe
with the new step
added to the sequence of existing steps (if any). For the
tidy
method, a tibble with columns terms
(the
columns that will be affected).
step_string2factor()
step_dummy()
data(okc) rec <- recipe(~ diet + location, data = okc) rec <- rec %>% step_string2factor(diet) factor_test <- rec %>% prep(training = okc, stringsAsFactors = FALSE, retain = TRUE) %>% juice # diet is a class(factor_test$diet) rec <- rec %>% step_factor2string(diet) string_test <- rec %>% prep(training = okc, stringsAsFactors = FALSE, retain = TRUE) %>% juice # diet is a class(string_test$diet) tidy(rec, number = 1)