R Language Missing values Using NAs of different classes


The symbol NA is for a logical missing value:

#[1] "logical"

This is convenient, since it can easily be coerced to other atomic vector types, and is therefore usually the only NA you will need:

x <- c(1, NA, 1)
#[1] "numeric"

If you do need a single NA value of another type, use NA_character_, NA_integer_, NA_real_ or NA_complex_. For missing values of fancy classes, subsetting with NA_integer_ usually works; for example, to get a missing-value Date:

# [1] "Date"