从R导出数据时出现错误 [英] I got an error when exporting data from R

查看:80
本文介绍了从R导出数据时出现错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我想使用此代码从R中导出结果时,

When I wanted to export my results from R with this code,

write.table(imp, "c:/immp.txt", sep="\t")

我收到此错误:

Error in as.data.frame.default(x[[i]], optional = TRUE, stringsAsFactors = stringsAsFactors) : 
  cannot coerce class ""mids"" to a data.frame

很抱歉,我是R的新手.谢谢您的帮助

Sorry for a simple question,I am new to R. Thanks for your help

推荐答案

似乎您正在尝试导出"mids"对象,而不是数据框.在使用write.table之前,您需要将其转换为数据帧,您应该可以使用complete()完成此操作:

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 )

根据需要调整数据选项.然后尝试使用write.table命令.

Adjust the options as necessary for your data. Then try your write.table command.

这篇关于从R导出数据时出现错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆