简体   繁体   English

从 R 导出数据时出错

[英]I got an error when exporting data from R

When I wanted to export my results from R with this code,当我想用这段代码从 R 导出我的结果时,

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抱歉问了一个简单的问题,我是 R 新手。感谢您的帮助

It looks like you're trying to export a "mids" object, as opposed to a data frame.看起来您正在尝试导出“mids”对象,而不是数据框。 You'll need to convert it to a data frame before using write.table, which you should be able to do with complete():在使用 write.table 之前,您需要将其转换为数据框,您应该可以使用 complete() 来做到这一点:

impframe <- complete( imp, action = "long", include = TRUE )

Adjust the options as necessary for your data.根据数据需要调整选项。 Then try your write.table command.然后试试你的 write.table 命令。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM