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
.