R: Make missing values explicit

fct_explicit_na {forcats} | R Documentation

## Make missing values explicit

### Description

This gives missing value an explicit factor level, ensuring that they appear in summaries and on plots.

### Usage

    fct_explicit_na(f, na_level = "(Missing)")

### Arguments

`f` | A factor (or character vector).
`na_level` | Level to use for missing values.

### Examples

    f1 <- factor(c("a", "a", NA, NA, "a", "b", NA, "c", "a", "c", "b"))
    table(f1)

    f2 <- fct_explicit_na(f1)
    table(f2)

[Package forcats version 0.3.0 Index]