Learn R Programming

mltools (version 0.3.4)

set_factor: Set Factor

Description

Convience 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

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

Run this code
# NOT RUN {
x <- c("a", "b", "c", "c")
y <- c("a", "d", "d")
set_factor(list(x, y))
set_factor(list(x, y), aggregationThreshold=1)
# }

Run the code above in your browser using DataLab