Utility to generate a new characteristic from a numeric variable

Description

It generates a data frame with a new predictive characteristic after the binning process.

Usage

1
smbinning.gen(df, ivout, chrname = "NewChar")

Arguments

df

Dataset to be updated with the new characteristic.

ivout

An object generated after smbinning.

chrname

Name of the new characteristic.

Value

A data frame with the binned version of the characteristic analyzed with smbinning.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# Package loading and data exploration
library(smbinning) # Load package and its data
data(chileancredit) # Load smbinning sample dataset (Chilean Credit)
chileancredit.train=subset(chileancredit,FlagSample==1)
chileancredit.test=subset(chileancredit,FlagSample==0)
result=smbinning(df=chileancredit.train,y="FlagGB",x="TOB",p=0.05) # Run and save result

# Generate new binned characteristic into a existing data frame
chileancredit.train=
smbinning.gen(chileancredit.train,result,"gTOB") # Update training sample
chileancredit=
  smbinning.gen(chileancredit,result,"gTOB") # Update population
sqldf("select gTOB,count(*) as Recs 
      from chileancredit group by gTOB") # Check new field counts