which.na
Determine Which Values are Missing Values or are IEEE Special Values

Description

Returns an integer vector describing which values in the input vector, if any, are missing or are IEEE special values.

Usage

which.na(x) 
which.nan(x) 
which.inf(x)
which.infinite(x)

Arguments

x an object, which should be of mode "logical", "numeric", or "complex".
Value
returns an integer vector containing the indices of elements in x that are missing or are IEEE special values, according to which function is called.
If there are no missing values or IEEE special values, the functions return an integer vector of length 0 (numeric(0)).
which.nareturns the indices of values in x that are missing or "Not a Number".
which.nanreturns the indices of values in x that are "Not a Number".
which.infreturns the indices of values in x that are infinite (positive or negative).
See Also
Arithmetic, is.finite, is.na.
Examples
# A non-zero number divided by zero creates infinity,
# zero over zero creates a NaN 
weird.values <- c(1/0, -20.9/0, 0/0, NA) 
which.inf(weird.values) 
# Produces:
# [1] 1 2 
which.nan(weird.values) 
# Produces:
#  [1] 3 
which.na(weird.values) 
# Produces:
#  [1] 3 4 
# In this example, the which.na expression and the subscript 
# expression involving is.na should return the same value 
which.na(weird.values) 
seq(along=weird.values)[is.na(weird.values)] 
Package terrUtils version 6.1.1-7
Package Index