binning: Binning

Description Usage Arguments Value Examples

View source: R/feature_creation.R

Description

This function creates particular bins of equal intervals based on the specified numeric column of a data frame.

Usage

1
binning(input, target, interval)

Arguments

input

an object of type data.frame. Preferably the output of reshapeData().

target

a mandatory character string defining the variable that is to be used for binning.

interval

a mandatory non-negative numeric value indicating the amount of bins.

Value

An object of type data.frame in the same form as data including additional binned column.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# create data frame with mandatory columns
data = data.frame('id'=rep(c(1:5), each=4),
      'type'=rep(c('Var1', "Var2"), times=10),
      'value'=rep(c(1:5), times=4),
      'date'=rep(seq(as.Date("2000/1/1"), by = "day", length.out=10), each=2))

# create rectangle version of user journey
dat = reshapeData(data)

# use function to perform binning on a chosen variable
dat_bin = binning(dat, target='Var1', interval=2)

LoneWolf6/UJ-Analysis documentation built on Sept. 16, 2020, 4:59 a.m.