powered by
Replace missing values in a vector using a function (by default the mean) on this vector.
impNA(x, fn = mean, ...)
Vector x with all missing values replaced
x
A numeric vector
A function to apply to all values in the vector x
Additional arguments to be passed to function fn
fn
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)
Run the code above in your browser using DataLab