numericToCategorical: numericToCategorical

Description Usage Arguments Value Examples

View source: R/numericToCategorical.R

Description

This function categorizes a numerical variable by binning

Usage

1
numericToCategorical(dset, col = "job", resp = "y", bins = 10, adjFactor = 0.5)

Arguments

dset

The data frame containing the data set

col

A character respresenting the name of the numeric attribute which we want to categorize

resp

A character respresenting the name of the binary outcome variable The binary outcome variable may be a factor with two levels or an integer (or numeric ) with two unique values

bins

A number denoting the number of bins.Default value is 10

adjFactor

A number or a decimal denoting what is to be added to the number of responses (binary outcome variable is 1 ) or to the number of non responses (binary outcome variable is 0) if either is zero for any level of the attribute

Value

A list containing the categorized attribute,a table of Information Values for the levels of the categorized attribute,the Information Value for the entire attribute,a table showing the response rates of the levels of the categorized attribute

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# Load the German_Credit data set supplied with this package

data("German_Credit")

# Create an empty list

l<-list()

# Call the function as follows.
#This will categorize the numeric variable Duration in the German_Credit dataset.

l<-numericToCategorical(German_Credit,col="Duration",resp="Good_Bad")


# To view the categorized variable

 l$categoricalVariable

 # To view the IV table of the levels of the categorized variable

 l$IVTable

 # To view the total IV value of the  categorized variable

 l$IV

 # To view the response rates of the levels of the categorized variable

 l$collapseLevels

CollapseLevels documentation built on July 1, 2020, 5:38 p.m.