问题
When I wanted to export my results from R with this code,
write.table(imp, "c:/immp.txt", sep="\t")
I got this error:
Error in as.data.frame.default(x[[i]], optional = TRUE, stringsAsFactors = stringsAsFactors) :
cannot coerce class ""mids"" to a data.frame
Sorry for a simple question,I am new to R. Thanks for your help
回答1:
It looks like you're trying to export a "mids" object, as opposed to a data frame. You'll need to convert it to a data frame before using write.table, which you should be able to do with complete():
impframe <- complete( imp, action = "long", include = TRUE )
Adjust the options as necessary for your data. Then try your write.table command.
来源:https://stackoverflow.com/questions/37149696/i-got-an-error-when-exporting-data-from-r