How to Convert NA to Factor Level in R

To convert NA to factor level in R, you can use the “addNA()” method.

Syntax

addNA(data)

Parameters

data: It is a factor.

Visual representation

Visual Representation of Converting NA to Factor Level in R

Example

ftor <- as.factor(c("K", "B", NA, "M", "L"))

print(ftor)

print("After converting NA to factor level")

print(addNA(ftor))

Output

Convert NA to Factor Level in R Program Output

That’s it!

Leave a Comment