step_factor2string will convert one or more factor
vectors to strings.
step_factor2string( recipe, ..., role = NA, trained = FALSE, columns = FALSE, skip = FALSE, id = rand_id("factor2string") ) # S3 method for step_factor2string tidy(x, ...)
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 be converted to strings. See
Not used by this step since no new variables are created.
A logical to indicate if the quantities for preprocessing have been estimated.
A character string of variables that will be
converted. This is
A logical. Should the step be skipped when the
recipe is baked by
A character string that is unique to this step to identify it.
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
columns that will be affected).
prep has an option
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.
library(modeldata) data(okc) rec <- recipe(~ diet + location, data = okc) rec <- rec %>% step_string2factor(diet) factor_test <- rec %>% prep(training = okc, strings_as_factors = FALSE) %>% juice # diet is a class(factor_test$diet)#>  "factor"rec <- rec %>% step_factor2string(diet) string_test <- rec %>% prep(training = okc, strings_as_factors = FALSE) %>% juice # diet is a class(string_test$diet)#>  "character"tidy(rec, number = 1)#> # A tibble: 1 x 3 #> terms ordered id #> <chr> <lgl> <chr> #> 1 diet FALSE string2factor_qApoE