anyNA
Quickly check for missing (NA) values

Description

Finds out if an object contains a missing NA value more quickly than any(is.na()).

Usage

anyNA(x)

Arguments

x An object.

Details

anyNA is an S3 generic function and methods may be written for it. The default method will not look at any attributes of an object nor more than one level into a recursive object.
Value
anyNA returns TRUE if x contains any NA or NaN values. Otherwise FALSE. For commonly used classes of objects this is equivalent to any(is.na(x)), but is more efficient since the search is done in compiled C++ code and it stops looking after finding the first missing value.
See Also
is.na, any.
Examples
anyNA(1:10) # FALSE 
anyNA(c(-3, NA, 16)) # TRUE 
anyNA(data.frame(X=1:5, Y=factor(letters[c(1:3,NA,5)]))) # TRUE
anyNA(data.frame(X=1:5, Y=factor(letters[c(1:3,NA,5)], exclude=NULL))) # FALSE
Package base version 4.0.0-28
Package Index