write.xlsx2怎么会没有遇到write.xlsx给出的相同错误?

write.xlsx2怎么会没有遇到write.xlsx给出的相同错误?,r,dataframe,r-xlsx,R,Dataframe,R Xlsx,我试图使用R中xlsx包中的“write.xlsx”将数据帧(21x21)写入excel文件,但收到以下错误: Error in .jcall(cell, "V", "setCellValue", value) : method setCellValue with signature ([Ljava/lang/String;)V not found In addition: Warning message: In if (is.na(value)) { : the condition

我试图使用R中xlsx包中的“write.xlsx”将数据帧(21x21)写入excel文件,但收到以下错误:

Error in .jcall(cell, "V", "setCellValue", value) : 
  method setCellValue with signature ([Ljava/lang/String;)V not found
In addition: Warning message:
In if (is.na(value)) { :
  the condition has length > 1 and only the first element will be used
我无法快速排除错误,所以我尝试了“write.xlsx2”,只是想看看它是否能工作,结果成功了

从我对这个函数的理解来看,区别在于它提供了比“write.xlsx”更好的性能,并且通常用于非常大的数据帧(100000+行)。我的数据帧只有21行关于“write.xlsx2”如何工作以及没有收到与“write.xlsx”相同的错误的任何想法?

以下是我用于xlsx和xlsx2的代码:

write.xlsx(data, file=fileName, showNA=FALSE, sheetName = "By Sector", row.names=FALSE, col.names=FALSE, append=FALSE)

write.xlsx2(data, file=fileName, showNA=FALSE, sheetName = "By Sector", row.names=FALSE, col.names=FALSE, append=FALSE)
请让我知道是否有助于查看数据帧