merge_category: Merge Category

Description Usage Arguments Value Examples

View source: R/data_transformation.R

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

1
merge_category(dat, char_list = NULL, ex_cols = NULL, m = 10, note = TRUE)

Arguments

dat

A data frame with x and target.

char_list

The list of charecteristic variables that need to merge categories, Default is NULL. In case of NULL,merge categories for all variables of string type.

ex_cols

A list of excluded variables. Default is NULL.

m

The minimum number of categories.

note

Logical, outputs info. Default is TRUE.

Value

A data.frame with merged category variables.

Examples

1
2
3
4
5
#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])

creditmodel documentation built on Jan. 7, 2022, 5:06 p.m.