recipes (version 0.1.4)

step_discretize: Discretize Numeric Variables

Description

step_discretize creates a a specification of a recipe step that will convert numeric data into a factor with bins having approximately the same number of data points (based on a training set).

Usage

step_discretize(recipe, ..., role = NA, trained = FALSE,
  objects = NULL, options = list(), skip = FALSE,
  id = rand_id("discretize"))

# S3 method for step_discretize tidy(x, ...)

Arguments

recipe

A recipe object. The step will be added to the sequence of operations for this recipe.

...

For step_discretize, the dots specify one or more selector functions to choose which variables are affected by the step. See selections() for more details. For the tidy method, these are not currently used.

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.

objects

The discretize() objects are stored here once the recipe has be trained by prep.recipe().

options

A list of options to discretize(). A defaults is set for the argument x. Note that the using the options prefix and labels when more than one variable is being transformed might be problematic as all variables inherit those values.

skip

A logical. Should the step be skipped when the recipe is baked by bake.recipe()? While all operations are baked when prep.recipe() is run, some operations may not be able to be conducted on new data (e.g. processing the outcome variable(s)). Care should be taken when using skip = TRUE as it may affect the computations for subsequent operations

id

A character string that is unique to this step to identify it.

x

A step_discretize object

Value

step_discretize returns 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 selectors or variables selected) and value (the breaks).