smbinning.factor.gen: Utility to generate a new characteristic from a factor...

Description Usage Arguments Value Examples

View source: R/smbinning.R

Description

It generates a data frame with a new predictive characteristic from a factor variable after applying smbinning.factor or smbinning.factor.custom.

Usage

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

Arguments

df

Dataset to be updated with the new characteristic.

ivout

An object generated after smbinning.factor or smbinning.factor.custom.

chrname

Name of the new characteristic.

Value

A data frame with the binned version of the original characteristic.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
# Load library and its dataset
library(smbinning) # Load package and its data
pop=smbsimdf1 # Set population
train=subset(pop,rnd<=0.7) # Training sample

# Binning a factor variable on training data
result=smbinning.factor(train,x="home",y="fgood")

# Example: Append new binned characteristic to population
pop=smbinning.factor.gen(pop,result,"g1home")

# Split training
train=subset(pop,rnd<=0.7) # Training sample

# Check new field counts
table(train$g1home)
table(pop$g1home)

Example output

Loading required package: sqldf
Loading required package: gsubfn
Loading required package: proto
Loading required package: RSQLite
Loading required package: partykit
Loading required package: grid
Loading required package: libcoin
Loading required package: mvtnorm
Loading required package: Formula
Warning message:
no DISPLAY variable so Tk is not available 

 01 = 'No' 02 = 'Yes' 
      1205        554 

 01 = 'No' 02 = 'Yes' 
      1734        766 

smbinning documentation built on May 1, 2019, 10:06 p.m.