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
objects.
Format
An object of class logical
of length 1.
An object of class integer
of length 1.
An object of class numeric
of length 1.
An object of class character
of length 1.
An object of class complex
of length 1.
Details
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_integer_
, NA_real_
, NA_character_
and
NA_complex_
. The missing value for logical vectors is simply the
default NA
. The aliases provided in rlang are consistently named
and thus simpler to remember. Also, na_lgl
is provided as an
alias to NA
that makes intent clearer.
Since na_lgl
is the default NA
, expressions such as c(NA, NA)
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
NA
.