Learn R Programming

dataPreparation (version 0.4.3)

build_bins: Compute bins

Description

Compute bins for discretization of numeric variable (either equal_width or equal_fred).

Usage

build_bins(
  dataSet,
  cols = "auto",
  n_bins = 10,
  type = "equal_width",
  verbose = TRUE
)

Arguments

dataSet

Matrix, data.frame or data.table

cols

List of numeric column(s) name(s) of dataSet to transform. To transform all characters, set it to "auto". (character, default to "auto")

n_bins

Number of group to compute (numeric, default to 10)

type

Type of discretization ("equal_width" or "equal_freq")

verbose

Should the algorithm talk? (Logical, default to TRUE)

Value

A list where each element name is a column name of data set and each element contains bins to discretize this column.

Details

Using equal freq first bin will start at -Inf and last bin will end at +Inf.

Examples

Run this code
# NOT RUN {
# Load data
data(messy_adult)
head(messy_adult)

# Compute bins
bins <- build_bins(messy_adult, cols = "auto", n_bins = 5, type = "equal_freq")
print(bins)
# }

Run the code above in your browser using DataLab