NALevel: Replace NAs in a Factor by a Given Level

View source: R/DescTools.r

NALevelR Documentation

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)

Arguments

x

a vector which will be turned into a factor.

level

the name for the new level

Value

the vector x with the NAs replaced by level

Author(s)

Andri Signorell <andri@signorell.net>

See Also

factor, levels

Examples

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


DescTools documentation built on Sept. 26, 2024, 1:07 a.m.