View source: R/step-binarize.r
step_binarize | R Documentation |
step_binarize()
creates a specification of a recipe step that will create
binary variables from categorical or numeric variables based on a provided
set of passing or failing values.
step_binarize( recipe, ..., role = NA, trained = FALSE, pass = NULL, fail = NULL, skip = FALSE, id = rand_id("binarize") )
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 are affected by the step. |
role |
Not used by this step since no new variables are created. |
trained |
A logical value indicating whether the values used for binarization have been checked. |
pass, fail |
Vectors of values, matched to the variables, to be coded as
|
skip |
A logical value indicating whether the step should be skipped
when the recipe is baked by |
id |
A character string that is unique to this step, used to identify it. |
At least one of pass
and fail
must be provided, and if both are
provided then values in neither will be converted to NA
. For easier
compatibility with other steps, binarization produces integer-valued
variables taking the values 0
and 1
rather than logical variables.
An updated version of recipe
with the new step added to the
sequence of existing steps (if any).
rec_test <- recipe(mtcars, mpg ~ .) %>% step_binarize(vs, am, pass = 1) %>% step_center(all_predictors(), -vs, -am) %>% step_scale(all_predictors(), -vs, -am) %>% prep() bake(rec_test, mtcars)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.