Skip to content

How to capture NA values

3 messages · Alaios, Berend Hasselman, David Winsemius

#
On 10-05-2012, at 17:16, Alaios wrote:

            
How about simply is.na?

Berend
#
On May 10, 2012, at 11:16 AM, Alaios wrote:

            
If you have a vector of mode 'integer' (or numeric) you can get their  
index locations with:

which(is.na(vec))

Logical tests for any NA's would be:

!length(which(is.na(vec)))

or

sum(is.na(vec))==0

or perhaps the most self-documenting method:

any(is.na(vec))