I got an error when exporting data from R

时间秒杀一切 提交于 2021-02-11 01:44:57

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!