impNA | R Documentation |
Replace missing values in a vector using a function (by default the mean) on this vector.
impNA(x, fn = mean, ...)
x |
A numeric vector |
fn |
A function to apply to all values in the vector |
... |
Additional arguments to be passed to function |
Vector x
with all missing values replaced
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.