set_factor: Set Factor

Description Usage Arguments Examples

View source: R/set_factor.R

Description

Convenience method for dealing with factors. Map a list of vectors to a list of factor vectors (1-1 mapping) such that the factor vectors all have the same levels - the unique values of the union of all the vectors in the list. Optionally group all low frequency values into a "_other_" level.

Usage

1
set_factor(vectorList, aggregationThreshold = 0)

Arguments

vectorList

A list of values to convert to factors

aggregationThreshold

Values which appear this many times or less will be grouped into the level "_other_"

Examples

1
2
3
4
x <- c("a", "b", "c", "c")
y <- c("a", "d", "d")
set_factor(list(x, y))
set_factor(list(x, y), aggregationThreshold=1)

ben519/mltools documentation built on Sept. 22, 2021, 4:30 p.m.