R Fix Error in Loading “xlsx” Package

read.xlsx () in “xlsx” package is a simple function that reads a sheet in .xlsx file.
In Windows, however, you need to do some set-up before using this function if you get this error:

Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl,  : java.lang.OutOfMemoryError: Java heap space

When you get this error, put this one line before loading “xlsx” package.

#### Set-Up #### 
options(java.parameters = "-Xmx1000m")
################

# For those who get an error when loading "xlsx" pacakge
if (Sys.getenv("JAVA_HOME")!="") {
 Sys.setenv(JAVA_HOME="")
}

library ("xlsx")

Now, you can enjoy read.xslx ()!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s