Learn R Programming

DescTools (version 0.99.56)

NALevel: Replace NAs in a Factor by a Given Level

Description

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.

Usage

NALevel(x, level)

Value

the vector x with the NAs replaced by level

Arguments

x

a vector which will be turned into a factor.

level

the name for the new level

Author

Andri Signorell <andri@signorell.net>

See Also

Examples

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

Run the code above in your browser using DataLab