R数据框到多页Excel工作

我试图将相当多的dataframe保存到一张多页的Excel表格中,并且出现了一些奇怪的错误。

library(xlsx) save.xlsx("WorkbookTitle.xlsx", mtcars, Titanic, iris) save.xlsx <- function (file, ...) { require(xlsx, quietly = TRUE) objects <- list(...) fargs <- as.list(match.call(expand.dots = TRUE)) objnames <- as.character(fargs)[-c(1, 2)] nobjects <- length(objects) for (i in 1:nobjects) { if (i == 1) write.xlsx(objects[[i]], file, sheetName = objnames[i]) else write.xlsx(objects[[i]], file, sheetName = objnames[i], append = TRUE) } print(paste("Workbook", file, "has", nobjects, "worksheets.")) } 

给了我一个实际的工作簿,但当我试图用我的数据框做到这一点,我得到这个错误:

 the condition has length > 1 and only the first element will be usedError in .jcall(cell, "V", "setCellValue", value) : method setCellValue with signature ([Ljava/lang/String;)V not found 

我删除了行名,但似乎没有工作。