如何不同的R输出追加到一个Excel的小号preadsheet [英] How to append different R outputs into one excel spreadsheet

查看:183
本文介绍了如何不同的R输出追加到一个Excel的小号preadsheet的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以每当我想单独运行我的code代表不同的数据集...我想从我的code的输出保存在同一个Excel US preadsheet但在不同的表... 。所以如果我跑我的code 20不同的数据集...我会想要保存在同一个Excel US preadsheet但不同的工作表中的所有输出...所以我想有20个工作表一个Excel US preadsheet ...有r中一个特殊的功能,它可以让我做到这一点?.....因此,可以说我现在的S preadsheet被称为Values​​.csv......会怎样我在我的其余输出将追加到这个相同的S preadsheet。

So whenever I want to run my code seperately for different datasets...I want the output from my code to be saved in the same excel spreadsheet but at different sheets....So If I run my code for 20 different datasets...I would want all the output to saved in the same excel spreadsheet but different worksheets...so I would have 20 worksheets in a single excel spreadsheet...is there a special function in r that would let me do this?.....so lets say my existing spreadsheet is called 'Values.csv'....How would I append the rest of my output to this same spreadsheet.

我通常只使用 write.csv(数据,'Values​​.csv')等....但我不知道怎么我的输出追加到此相同的工作表...

I usually just use write.csv(data,'Values.csv') etc....But I'm not sure how to append my output to this same worksheet...

推荐答案

您可以使用库 XLConnect 来做到这一点。

You can use library XLConnect to do this.

library(XLConnect)

#some sample data
your.data=data.frame(a=1:10,b=21:30)

#Create .xls file
wb <- loadWorkbook("newfile.xls", create = TRUE)

#Create Sheet in file
createSheet(wb,name="name_one")

#write data
writeWorksheet(wb,your.data,sheet="name_one")

#save .xls file
saveWorkbook(wb)

这篇关于如何不同的R输出追加到一个Excel的小号preadsheet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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