问题
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.
I usually just use write.csv(data,'Values.csv')
etc....But I'm not sure how to append my output to this same worksheet...
回答1:
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)
来源:https://stackoverflow.com/questions/15676104/how-to-append-different-r-outputs-into-one-excel-spreadsheet