group.factor: Put rare factor values into separate group

Description Usage Arguments Value Examples

Description

Sets rare values of a factor to new value "other". Thus limits the number of factor levels.

Usage

1
group.factor(x, top.values = 10, min.frequency = NA)

Arguments

x

data vector

top.values

number of bins to create (plus "other" group)

min.frequency

if factor value is less requent than this value, then put it to "other" group

Value

data frame with mapping (variable value) -> (variable group)

Examples

1
2
df$var <- group.factor(df$var, top.values=10)
df$var <- group.factor(df$var, min.frequency=100)

konstantin-kotochigov/ML-UTILS documentation built on May 17, 2019, 7:30 p.m.