【问题标题】:write list of dataframes to xls using WriteXLS使用 WriteXLS 将数据帧列表写入 xls
【发布时间】:2015-06-22 15:43:30
【问题描述】:

我找不到文档来回答我看似简单的问题。

为简单起见,我列出了 3 个不同行数的数据框。

mylist<-list() 
mylist[[1]]<-c(1:10)
mylist[[2]]<-c(2:15)
mylist[[3]]<-c(20:54)

我想将列表中的每个元素写入 Excel 工作簿中的单独工作表,我大概可以使用 WriteXLS (?)。

当我打电话时

WriteXLS("mylist", ExcelFileName="mylist.xls")
Error in WriteXLS("mylist", ExcelFileName = "mylist.xls") : 
One or more of the objects named in 'x' is not a data frame or does not exist

...WriteXLS 不支持列表吗?如果没有,我如何有效地解决这个问题?我将编写文件作为大型模拟的一部分。

【问题讨论】:

    标签: r excel export-to-excel


    【解决方案1】:

    我总是创建临时数据框(矩形数组)...

    sheet0 <- data.frame(array.no.1)   # This is usually set of descriptions of the sheets
    sheet1 <- data.frame(array.no.2)   # The data
    sheet2 <- data.frame(array.no.3)   # More information 
    myxls <- c(sheet0="Index",sheet1="Results",sheet2="Notes")
    
    WriteXLS(names(myxls),ExcelFileName="my.xls",SheetNames=myxls)
    

    文档说“data.frames”,所以我找到了这个解决方案。

    【讨论】:

      猜你喜欢
      • 2013-11-01
      • 1970-01-01
      • 2015-01-02
      • 1970-01-01
      • 2020-08-25
      • 2019-09-01
      • 2020-11-26
      • 1970-01-01
      • 2013-08-08
      相关资源
      最近更新 更多