I agree with @orville Jackson's answer and it really helped me.
Embed the answer provided by @orville jackson. here is a detailed description of how you can use openxlsx to read and write large files.
When the data size is small, R has many packages and functions that can be used to suit your requirements.
write.xlsx, write.xlsx2, XLconnect also do the job, but sometimes they are slow compared to openxlsx.
So, if you are dealing with large data sets and have encountered Java errors. I would suggest looking at "openxlsx", which is really awesome and cutting time by 1 / 12th.
I tested everything, and finally, I was impressed with the performance capabilities of openxlsx.
Below are the steps to write multiple datasets onto multiple sheets.
install.packages("openxlsx") library("openxlsx") start.time <- Sys.time() # Creating large data frame x <- as.data.frame(matrix(1:4000000,200000,20)) y <- as.data.frame(matrix(1:4000000,200000,20)) z <- as.data.frame(matrix(1:4000000,200000,20)) # Creating a workbook wb <- createWorkbook("Example.xlsx") Sys.setenv("R_ZIPCMD" = "C:/Rtools/bin/zip.exe") ## path to zip.exe
Sys.setenv ("R_ZIPCMD" = "C: /Rtools/bin/zip.exe") must be static, as it requires a link to some utility from Rtools.
Note. Incase Rtools is not installed on your system, first install it to ensure a smooth transition. here is the link for your reference: (select the appropriate version) https://cran.r-project.org/bin/windows/Rtools/
check the settings in accordance with the link below (you need to check the box during installation) https://cloud.githubusercontent.com/assets/7400673/12230758/99fb2202-b8a6-11e5-82e6-836159440831.png
# Adding a worksheets : parameters for addWorksheet are 1. Workbook Name 2. Sheet Name addWorksheet(wb, "Sheet 1") addWorksheet(wb, "Sheet 2") addWorksheet(wb, "Sheet 3")
the openxlsx package is really good for reading and writing huge data from / to excel files and has many options for custom formatting in excel.
An interesting fact is that we should not worry about the memory of the java heap here.