bin_numeric_variable: Convert a numeric variable to a discrete one

View source: R/convenience-functions.R

bin_numeric_variableR Documentation

Convert a numeric variable to a discrete one

Description

A wrapper around dplyr::ntile() to bin a numeric feature into a discrete one.

Usage

bin_numeric_variable(df, num_variable, discr_variable, n_bins)

Arguments

df

A data.frame containing at least the numeric variable specified in num_variable.

num_variable

Character value. The name of the numeric variable that you want to convert.

discr_variable

Character value. The name the new discrete variable wil have.

n_bins

Numeric value. The number of bins you want to distribute the values of num_variable to. Given to argument n of dplyr::ntile().

Value

The data.frame specified in data with the additional discrete variable.


kueckelj/confuns documentation built on July 4, 2024, 4:53 p.m.