step_discretize: Discretize Numeric Variables

Description Usage Arguments Details Value See Also

View source: R/discretize.R

Description

step_discretize creates 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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
step_discretize(
  recipe,
  ...,
  role = NA,
  trained = FALSE,
  num_breaks = 4,
  min_unique = 10,
  objects = NULL,
  options = list(),
  skip = FALSE,
  id = rand_id("discretize")
)

Arguments

recipe

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

...

One or more selector functions to choose variables for this step. See selections() for more details.

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.

num_breaks

An integer defining how many cuts to make of the data.

min_unique

An integer defining a sample size line of dignity for the binning. If (the number of unique values)/(cuts+1) is less than min_unique, no discretization takes place.

objects

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

options

A list of options to discretize(). A default is set for the argument x. Note that 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.

Details

When you tidy() this step, a tibble with columns terms (the selectors or variables selected) and value (the breaks) is returned.

Value

An updated version of recipe with the new step added to the sequence of any existing operations.

See Also

Other discretization steps: step_cut()


recipes documentation built on Sept. 27, 2021, 5:09 p.m.