Learn R Programming

funModeling (version 1.6.8)

equal_freq: Equal frequency binning

Description

Equal frequency tries to put the same quantity of cases per bin when possible. It's a wrapper of function cut2 from Hmisc package.

Usage

equal_freq(var, n_bins)

Arguments

var

input variable

n_bins

number of bins to split 'var' by equal frequency, if it not possible to calculate for the desired bins, it returns the closest number

Value

The binned variable.

Examples

Run this code
# NOT RUN {
## Example 1
summary(heart_disease$age)
age_2=equal_freq(var=heart_disease$age, n_bins = 10)
summary(age_2)

## Example 2
age_3=equal_freq(var=heart_disease$age, n_bins = 5)
summary(age_3)
# }

Run the code above in your browser using DataLab