R: Not Available / ``Missing'' Values

NA {base} | R Documentation

## Not Available / ``Missing'' Values

### Description

`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 `is.na` 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 generic function `is.na<-` sets elements to `NA`.

### Usage

    NA
    is.na(x)
    is.na.data.frame(x)

    is.na(x) <- value

### Arguments

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

### Details

For character vectors the value `"NA"` represents missingness.

`is.na(x)` works elementwise when `x` is a `list`. The method dispatching is C-internal, rather than via `UseMethod`.

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

### See Also

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

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

### Examples

    is.na(c(1,NA))       #> F TRUE
    is.na(paste(c(1,NA)))#> F FALSE

[Package Contents]