I am currently attempting to use R to read a (large, 8.3 MB) .xlsx file into a matrix. I am attempting to do so with the read.xlsx file in the xlsx package. https://cran.r-project.org/web/packages/xlsx/index.html
I am now trying to read the contents of one of the sheets in the file with the following command:
sheetname<-read.xlsx("/Users/jinkinsonsmith/Downloads/Re _Introduction/filename.xlsx",sheetName='sheetname')
It looks like this command should work in terms of reading the contents of sheet "sheetname" in xlsx file "filename" into the vector "sheetname". However, instead, I am getting this error message:
Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl, : java.lang.OutOfMemoryError: Java heap space
It seems like I'm not the first person to get this error message (example: How to deal with "java.lang.OutOfMemoryError: Java heap space" error?), but even after reading the other post I just linked it is still not clear to me what I should do to fix this error. My MacBook Pro has long had issues with running out of disk space and requiring me to delete a bunch of files, so that could be the culprit, but it is also apparently possible that I have too many stored references to objects in R that I no longer use and that are taking up too much space. In the latter case I don't know how I would remove any unneeded references.