rem_sparse_cat: Remove sparse categories

Description Usage Arguments Details Value Examples

View source: R/rem_sparse_cat.R

Description

Remove sparse categories

Usage

1
rem_sparse_cat(x, threshold, label = "(Other)")

Arguments

x

factor variable

threshold

threshold

label

label for the new category

Details

Combines levels with strictly less than threshold number of observations into a new category. NA are ignored.

Value

factor variable

Examples

1
2
3
4
 a <- rpois(100,1)
 k <- length(unique(a))
 a <- factor(a, labels=LETTERS[1:k])
 rem_sparse_cat(a, threshold=20)

sumtxt/datatools documentation built on Jan. 3, 2021, 1:39 a.m.