combineLevels {gdata}R Documentation

Combine levels of given factors

Description

combineLevels combines levels of given factors and applies this levels to given factors. This eases the work with factors since all factors have the same levels.

Usage

combineLevels(x, apply=TRUE, drop=FALSE)

Arguments

x data.frame or list, object with factors
apply boolean, apply combined levels to x or just return combined levels
drop boolean, drop unused levels

Value

apply handles the output. If apply=TRUE the output is a modified x, where all factors have the same set of levels. If apply=FALSE only combined levels are returned.

Author(s)

Gregor Gorjanc

See Also

factor, levels, mapFactor

Examples


(f1 <- factor(letters[1:5]))
(f2 <- factor(letters[3:10]))
tmp <- list(f1, f2)
combineLevels(tmp)
combineLevels(tmp, apply=FALSE)

f1[2] <- NA
f1 <- factor(f1)
tmp <- list(f1, f2)
combineLevels(tmp, apply=FALSE, drop=TRUE)


[Package gdata version 2.2.0 Index]