Learn R Programming

creditmodel (version 1.0)

merge_category: Merge Category

Description

merge_category is for merging category of nominal variables which number of categories is more than m or percent of samples in any categories is less than p.

Usage

merge_category(dat, ex_cols = "date$|id$|time$|DATA$|ID$|TIME$",
  p = 0.01, m = 10, note = FALSE)

Arguments

dat

A data frame with x and target.

ex_cols

A list of excluded variables. Default is NULL.

p

The minimum percent of samples in a category to merge.

m

The minimum number of categories.

note

Logical, outputs info. Default is TRUE.

Value

A data.frame with merged category variables.

Examples

Run this code
# NOT RUN {
#merge_catagory
dat =  merge_category(lendingclub,ex_cols = "id$|_d$")
char_list = get_names(dat = dat,types = c('factor', 'character'),
ex_cols = "id$|_d$", get_ex = FALSE)
str(dat[,char_list])
# }

Run the code above in your browser using DataLab