Missing & Special Values
missing value (typed: NA_integer_, NA_real_, NA_character_) absence of an object (length 0) not a number (0/0) infinity (1/0) is.infinite(), is.finite()
x <- c(1, NA, 3)
sum(x) # NA — missingness propagates
sum(x, na.rm = TRUE) # 4
mean(x, na.rm = TRUE)
is.na(x) # FALSE TRUE FALSE
x == NA # NA NA NA — never use == to test for NA!
anyNA(x)
x[!is.na(x)]
complete.cases(df) # rows without NA
na.omit(df)
NA > 1 # NA
NA & FALSE # FALSE (result is known regardless)
NA^0 # 1
length(NULL) # 0
c(1, NULL, 2) # 1 2 — NULL disappears