combineLevels {gdata} | R Documentation |
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.
combineLevels(x, apply=TRUE, drop=FALSE)
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 |
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.
Gregor Gorjanc
(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)