NAtoCategory: Change NAs in a factor into a category

Description Usage Arguments Value Author(s) Examples

View source: R/NAtoCategory.r

Description

Extract all the missing values in a factor variable and turn them into a separate category.

Usage

1
NAtoCategory(fact, label = "missing")

Arguments

fact

Factor variable.

label

Label to be given to the missing valus.

Value

Updated factor variable.

Author(s)

Kaspar Rufibach (maintainer), kaspar.rufibach@gmail.com,
http://www.kasparrufibach.ch

Examples

1
2
3
4
set.seed(1977)
fact <- factor(sample(c(round(runif(10, 1, 3)), rep(NA, 10))), levels = 1:3, 
    labels = c("no", "maybe", "yes"))
NAtoCategory(fact)

reporttools documentation built on May 30, 2017, 8:11 a.m.

Search within the reporttools package
Search all R packages, documentation and source code