rstudio 导出结果,如何将回归分析的系数从RStudio导出到电子表格或csv文件?

在RStudio中进行回归分析后,用户试图使用`coef()`函数将系数导出到CSV文件,但遇到了错误。解决方案是使用`broom`包,该包能将模型输出转换为易于操作的数据框。通过安装和应用`broom`,可以将整理后的模型结果写入CSV文件。
摘要由CSDN通过智能技术生成

I am new to RStudio and I guess my question is pretty easy to solve but a lot of searching did not help me.

I am running a regression and summary(regression1) shows me all the coefficients and so on.

Now I am using coef(regression1) so it only gives me the coefficients which I want to export to a file.

write.csv(coef, file="regression1.csv) and the "Error in as.data.frame.default(x[[i]], optional = TRUE) : cannot coerce class ""function"" to a data.frame" occurs.

Would be great If you could help me. I am searching the web for a few hours now and was not successful.

Do I have to change coef somehow so it fits in a data.frame?

Thank you very much!

解决方案

There's a contributed package called broom that simplifies this task, it converts model output to tidy dataframes. Here's a self-contained repro

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值