Test For Missing Values - Generic function

DESCRIPTION:

Returns an object similar to the input which is filled with logicals denoting whether the corresponding element of the input is NA.

This function is an S Version 3 generic (see Methods); method functions can be written to handle specific S Version 3 classes of data. Classes which already have methods for this function include:
data.frame, bdFrame, factor.

USAGE:

is.na(x) 

REQUIRED ARGUMENTS:

x
a S-PLUS object, which should be logical, numeric, or complex.

VALUE:

a logical object like x, with TRUE wherever there is an NA in x and FALSE elsewhere. Note that is.na returns TRUE for NaN values, which are generated by mathematically indeterminate expressions such as Inf - Inf. To test whether a value is a NaN, use the is.nan.

CLASSES:

This function will be used as the default method for classes that do not inherit a specific method for the function The result will retain the class and the attributes. If this behavior is not appropriate, the designer of the class should provide a method for the function.

WARNING:

This is always FALSE when x is of mode "character".

SEE ALSO:

, , , .

EXAMPLES:

# if function transform(y) cannot take NA's: 
y.ok <- !is.na(y) 
y[y.ok] <- transform(y[y.ok]) 
# Specific example, involving log:
y <- c(1, NA, 4)
y[!is.na(y)] <- log(y[!is.na(y)])

# Two ways to test whether an object has missing values:
any(is.na(y))
(length(which.na(y)) > 0)
# Using which.na() may save memory; is.na() creates a logical vector
# the same length as y, which.na() creates a vector whose length is
# only equal to the number of missing values