[R] Mean or mode imputation fro missing values
francesca casalino
francy.casalino at gmail.com
Tue Oct 11 14:11:14 CEST 2011
Dear R experts,
I have a large database made up of mixed data types (numeric,
character, factor, ordinal factor) with missing values, and I am
looking for a package that would help me impute the missing values
using either the mean if numerical or the mode if character/factor.
I maybe could use replace like this:
df$var[is.na(df$var)] <- mean(df$var, na.rm = TRUE)
And go through all the many different variables of the datasets using
mean or mode for each, but I was wondering if there was a faster way,
or if a package existed to automate this (by doing 'mode' if it is a
factor or character or 'mean' if it is numeric)?
I have tried the package "dprep" because I wanted to use the function
"ce.mimp", btu unfortunately it is not available anymore.
Thank you for your help,
-francy
More information about the R-help
mailing list