If I want to check whether an element in a list is missing, sometimes it's NA, but sometimes it is simply a vector of length 0. This checks for both possibilities.

is_mt_or_na(x)

Arguments

x

A vector of any type, of length 0 or 1

Value

TRUE if the vector has length 0 or is NA

Examples

is_mt_or_na(character(0))
#> [1] TRUE
is_mt_or_na(NA_character_)
#> [1] TRUE
is_mt_or_na("foo")
#> [1] FALSE