NA {base}R Documentation

Not Available / “Missing” Values


NA is a logical constant of length 1 which contains a missing value indicator. NA can be freely coerced to any other vector type.

The generic function indicates which elements are missing.

The generic function<- sets elements to NA.


## S3 method for class 'data.frame': <- value


x an R object to be tested.
value a suitable index vector for use with x.


The NA of character type is as from R 1.5.0 distinct from the string "NA". Programmers who need to specify an explicit string NA should use as.character(NA) rather than "NA", or set elements to NA using<-. works elementwise when x is a list. The method dispatching is C-internal, rather than via UseMethod.

Function<- may provide a safer way to set missingness. It behaves differently for factors, for example.


The default method for returns a logical vector of the same “form” as its argument x, containing TRUE for those elements marked NA or NaN (!) and FALSE otherwise. dim, dimnames and names attributes are preserved.
The method returns a logical matrix with the same dimensions as the data frame, and with dimnames taken from the row and column names of the data frame.


Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. Wadsworth & Brooks/Cole.

Chambers, J. M. (1998) Programming with Data. A Guide to the S Language. Springer.

See Also

NaN, is.nan, etc., and the utility function complete.cases.

na.action, na.omit, on how methods can be tuned to deal with missing values.

Examples, NA))        #> FALSE  TRUE, NA))) #> FALSE FALSE

[Package base version 2.1.0 Index]