azadag
7/28/2016 - 6:57 PM

combine 4 factors ino two

x <- c("female", "f", "male", "m", "f", "undeclared")
y <- factor(x)
y
# [1] female     f          male       m          f          undeclared
# Levels: f female m male undeclared
levels(y) <- list("female" = c("female", "f"),
                  "male" = c("male", "m"),
                  "undeclared" = "undeclared")
y
# [1] female     female     male       male       female     undeclared
# Levels: female male undeclared