na.replace: Replace Missing Values

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/na.replace.R

Description

Replace missing values

Usage

1

Arguments

x

vector possibly contining missing (NA) values

replace

either a scalar replacement value, or a function returning a scalar value

...

Optional arguments to be passed to replace

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 [email protected]

See Also

is.na, na.omit

Examples

1
2
3
4
5
6
7
   x <- c(1,2,3,NA,6,7,8,NA,NA)
   
   # Replace with a specified value
   na.replace(x, '999')
   
   # Replace with the calculated median
   na.replace(x, median, na.rm=TRUE)    

gtools documentation built on June 26, 2018, 5:01 p.m.

Related to na.replace in gtools...