powered by

In order to replace the NAs in a factor an additional level has to be defined first. This function does this and replaces the NAs by the given level.

NALevel(x, level)

the vector x with the NAs replaced by level

a vector which will be turned into a factor.

the name for the new level

Andri Signorell <andri@signorell.net>

factor, levels

factor

levels

x <- c(LETTERS[1:5], NA) table(NALevel(x, "something else"))

Run the code above in your browser using DataLab