superFactor: Create a factor with unobserved levels

Description Usage Arguments Value Examples

View source: R/merData.R

Description

Create a factor variable and include unobserved levels for compatibility with model prediction functions

Usage

1
superFactor(x, fullLev)

Arguments

x

a vector to be converted to a factor

fullLev

a vector of factor levels to be assigned to x

Value

a factor variable with all observed levels of x and all levels of x in fullLev

Examples

1
2
3
4
5
6
7
regularFactor <- c("A", "B", "C")
regularFactor <- factor(regularFactor)
levels(regularFactor)
# Now make it super
newLevs <- c("D", "E", "F")
regularFactor <- superFactor(regularFactor, fullLev = newLevs)
levels(regularFactor) # now super

merTools documentation built on June 5, 2018, 9:04 a.m.