impNA {smallstuff} | R Documentation |
Impute Missing Values
Description
Replace missing values in a vector using a function (by default the mean) on this vector.
Usage
impNA(x, fn = mean, ...)
Arguments
x |
A numeric vector |
fn |
A function to apply to all values in the vector |
... |
Additional arguments to be passed to function |
Value
Vector x
with all missing values replaced
Examples
v1=c(2,5,3,NA,2,4,1,NA)
#Replace values with the mean
impNA(v1,na.rm=TRUE)
#Replace values with the minimum
impNA(v1,min,na.rm=TRUE)
[Package smallstuff version 1.0.3 Index]