Skip to contents

[Stable]

Substitute missing data with a string or factor level.

Usage

explicit_na(x, label = "<Missing>")

Arguments

x

factor or character vector

label

character string that missing data should be replaced with

Examples

explicit_na(c(NA, "a", "b"))
#> [1] "<Missing>" "a"         "b"        
is.na(explicit_na(c(NA, "a", "b")))
#> [1] FALSE FALSE FALSE

explicit_na(factor(c(NA, "a", "b")))
#> [1] <Missing> a         b        
#> Levels: a b <Missing>
is.na(explicit_na(factor(c(NA, "a", "b"))))
#> [1] FALSE FALSE FALSE

explicit_na(sas_na(c("a", "")))
#> [1] "a"         "<Missing>"