I was trying to write a dataframe (21x21) to an excel file using "write.xlsx" from the xlsx package in R but was receiving the below error:
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
I wasn't able to quickly troubleshoot the error, so I tried "write.xlsx2" just to see if it would work, and it did.
From my understanding of this function, the difference is that it provides better performance than "write.xlsx" and is typically used for very large dataframes (100,000+ rows). My dataframe is only 21 rows. Any ideas on how "write.xlsx2" worked and didn't receive the same error as "write.xlsx"?
Here's the code I used for both xlsx and 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)
Please let me know if it would help to see the dataframe.