R: Replace Missing Values

na.replace {gtools} | R Documentation

## Replace Missing Values

### Description

Replace missing values

### Usage

    na.replace(x, replace)

### Arguments

`x` | vector possibly contining missing (`NA`) values.
`replace` | scalar replacement value

### Details

This is a convenience function that is the same as x[is.na(x)] <- replace

### Value

Vector with missing values (`NA`) replaced by the value of `replace`.

### Author(s)

Gregory R. Warnes greg@warnes.net

### See Also

`is.na`, `na.omit`

### Examples

       x <- c(1,2,3,NA,6,7,8,NA,NA)
       na.replace(x, '999')

[Package gtools version 3.5.0 Index]