equal_freq: Equal frequency binning

View source: R/cross_plot.R

equal_freqR Documentation

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

## 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)

funModeling documentation built on May 29, 2024, 3:24 a.m.