John Smith
2007-May-10 17:47 UTC
[R] Need help imputing missing data using mice and outputting them
Hello!
I am trying to impute missing data and output the results of the imputation.
My data set is called: MyData.
I have a bunch of variables all of which start with Q20_ - and some of them have
missing values.
Here is what I've been doing:
imputationmodel<-mice( MyData[ c (grep("Q20_", names(MyData)) ) ] )
multipledataset<-complete(imputationmodel,action="long")
write.table(as.data.frame(lapply(multipledataset,function(x)
{as.numeric(is.element(x,5))} )),
sep="\t",file="multiset.txt",row.names=F)
The last line (write.table) makes it so that all the values get changed into 0s
and 1s. How could I output the original imputed values (in my case, they should
be 1s or 2s or 3s or 4s or 5s) rather than 0s and 1s?
Thank you very much!
Dimitri
__________________________________________________
[[alternative HTML version deleted]]
