Skip to content
Prev 325756 / 398503 Next

an issue about removing "NA"s from an array

Read 'An Introduction to R', found on the R web site.  It is short and worth reading in its entirety.  Section 2.5 on missing values answers your question:

  2.5 Missing values
  
In some cases the components of a vector may not be completely known. When an element or value is "not available" or a "missing value" in the statistical sense, a place within a vector may be reserved for it by assigning it the special value NA. In general any operation on an NA becomes an NA. The motivation for this rule is simply that if the specification of an operation is incomplete, the result cannot be known and hence is not available.

The function is.na(x) gives a logical vector of the same size as x with value TRUE if and only if the corresponding element in x is NA.

     > z <- c(1:3,NA);  ind <- is.na(z)
Notice that the logical expression x == NA is quite different from is.na(x) since NA is not really a value but a marker for a quantity that is not available. Thus x == NA is a vector of the same length as x all of whose values are NA as the logical expression itself is incomplete and hence undecidable.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com