The "mydata" data frame has 128,000 rows. When I write it to an xlsx file it just keep running and when I stop it I get the error:
write.xlsx(x = mydata, file = "myfile.xlsx",
sheetName = "Sheet1", row.names = FALSE)
Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl, :
java.lang.OutOfMemoryError: Java heap space
Do you know what this means?
I advise you not to use those libraries (write.xlsx2 & write.xlsx), indeed both are suffering about data size and a lot of format construction. The simplest way to write a dataframe (I suppose your original data is in a dataframe structure or it's possible to transform them to a dataframe) is using writexl library. Here there is an example:
library(writexl)
df <- data.frame(name = c("Jon", "Bill", "Maria"),
age = c(23,41,32))
xlx_store_path <- "where do you want to store the .xlsx file"
write_xlsx(df, xlx_store_path)
Complete suorce here: https://datatofish.com/export-dataframe-to-excel-in-r/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With