Missing values are represented in R with the general symbol
NA. They can be inserted in almost all data containers: all
atomic vectors except raw vectors can contain missing values. To
achieve this, R automatically converts the general
NA symbol to a
typed missing value appropriate for the target vector. The objects
provided here are aliases for those typed
na_lgl na_int na_dbl na_chr na_cpl
An object of class
logical of length 1.
Typed missing values are necessary because R needs sentinel values
of the same type (i.e. the same machine representation of the data)
as the containers into which they are inserted. The official typed
missing values are
NA_complex_. The missing value for logical vectors is simply the
NA. The aliases provided in rlang are consistently named
and thus simpler to remember. Also,
na_lgl is provided as an
NA that makes intent clearer.
na_lgl is the default
NA, expressions such as
yield logical vectors as no data is available to give a clue of the
target type. In the same way, since lists and environments can
contain any types, expressions like
list(NA) store a logical
The vector-along family to create typed vectors filled with missing values.
typeof(NA)#>  "logical"typeof(na_lgl)#>  "logical"typeof(na_int)#>  "integer"# Note that while the base R missing symbols cannot be overwritten, # that's not the case for rlang's aliases: na_dbl <- NA typeof(na_dbl)#>  "logical"