I'm using aregImpute to impute missing values on a R dataframe (bn_df).
The code is this:
library(Hmisc)
impute_arg <- aregImpute(~ TI_Perc + AS_Perc +
CD_Perc + CA_Perc + FP_Perc,
data = bn_df, n.impute = 5)
It works fine.
The problem is after. In putting the values back into the original dataframe.
I can do it, just not in a very elegant way. I basically have to copy/paste the following line for all columns:
bn_df$CD_Perc[impute_arg$na$CD_Perc] <- impute_arg$imputed$CD_Perc[,1]
bn_df$FP_Perc[impute_arg$na$FP_Perc] <- impute_arg$imputed$FP_Perc[,1]
...
This works. But there has to be a more efficient way to accomplish this without copy/paste for all columns.
Any ideas?