-
Notifications
You must be signed in to change notification settings - Fork 13
Installation
The loadeR
package relies on the powerful capabilities of the Unidata's netCDF-Java libraries. An in-house version of this open source software (v4.6-SNAPSHOT) is currently used by loadeR.java. The connection between R and Java is established through rJava. Thus, loadeR
depends on the packages loadeR.java
and rJava
.
(1) Install the rJava
package available on CRAN. This installation can be troublesome (it depends on the correct configuration of Java paths in R). You can check the available Java version for an R session by Sys.getenv("JAVA_HOME")
: Make sure that the output is the path for a Java version 1.7 or higher before you install rJava. Note that the default configuration can be different for R and RStudio, and also if you open the applications directly from the terminal; see the information below if you find problems in this step (both the general and OS specific).
(2) Install loadeR
and the companion loadeR.java
packages (requires the R package devtools
):
devtools::install_github(c("SantanderMetGroup/loadeR.java", "SantanderMetGroup/loadeR"))
(3) The loadeR
package requires Java version 1.7 or higher. In order to detect possible problems in advance, a message with the Java version used by R will be given on loadeR
start. Check the startup messages and upgrade the Java version if a warning is given (see the information below if you find problems in this step).
We strongly recommend performing the installation directly from the default R GUI, to avoid further problems e.g. with RStudio. In Linux, system installation is recommended (e.g. in Debian-like systems sudo apt-get install r-cran-rjava
).
Because an adequate configuration of R and Java can be troublesome, as reported by some users, this section gives some basic information on how to proceed when things do not work fine on the first go.
In some cases, during the installation of rJava
, an error message of this type may appear:
ERROR: configuration failed for package ‘rJava’
This type of error most often appears when R does not find Java support in your system. In other words, R can't figure out where Java is located in your system. In this case, the environment variable JAVA_HOME must be set to point to a specific JRE/JDK, either through the command line or within the R environment (this is detailed in the R documentation).
From R, it is possible to check the JAVA_HOME path by typing:
Sys.getenv("JAVA_HOME")
This will return an empty value if this variable is not set. We can manually set it within R using Sys.setenv
. Typical settings for Linux, windows and MacOSX follow:
Sys.setenv(JAVA_HOME = "JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.51-4.b16.fc21.x86_64/jre") #Linux
Sys.setenv(JAVA_HOME="C:\\Program Files (x86)\\Java\jdk1.7.0\\jre") #Windows
Sys.setenv(JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre") #MacOSx
After this, it is necessary to run R CMD javareconf
from a terminal to update the settings (this requires superuser privileges, or alternatively running ~$ R CMD javareconf -e
).
This issue is discussed in more detail at the [http://r.789695.n4.nabble.com/rjava-JDK-not-found-td889163.html R-help forum].
On linux systems, some issues after java upgrade have been reported. Reboot may be required after java version upgrades.
A useful thread for Debian and similar distributions (Ubuntu...) related to the configuration of Java is given here.
Help on rJava
package installation is given here
As a general rule, it is highly recommended to install rJava
from the terminal, for instance using apt install
or similar.
This error usually arises if the java development kit is not installed. In Ubuntu:
~$ sudo apt install openjdk-X-jdk
(X corresponds to the version in use)
This error reads something like:
libjvm.so: cannot open shared object file: No such file or directory
at the end of a non-zero exit status attempt to install rJava
. In this case, it is necessary to explicitly indicate the appropriate LD_LIBRARY_PATH, that should read something like:
~$ export LD_LIBRARY_PATH=/usr/lib/jvm/java-8-oracle/lib/amd64:/usr/lib/jvm/java-8-oracle/jre/lib/amd64/server
~$ sudo R CMD javareconf
, adapted to the particular java version you are using. More information in this issue in the Ubuntu forum.
It is strongly recommended to run R (or RStudio) from the terminal instead of directly clicking on the application icon
~$ R
~$ /Applications/RStudio.app/Contents/MacOS/RStudio
Note that the Java version accesible from RStudio and from the R application can be different, and different from the R application directly opened from the terminas (as shown above). So, first of all make sure that Java is accesible from the R session:
Sys.getenv("JAVA_HOME")
Mac OS X comes with a preinstalled Java version. In this case, even if a newer version of Java is installed, it is sometimes troublesome changing the default Java version to be used by R (or RStudio) to a newer one. You can see which version is used in an R session when loading the loadeR
package (library('loadeR')
gives a message with the Java version). If the old version (1.6) is loaded by default, try
~$ sudo R CMD javareconf
(from the terminal)
and
install.packages('rJava', type='source')
(from R)
Some links with further information follow:
- Java and OS X: http://stackoverflow.com/questions/26948777/how-can-i-make-java-use-the-newer-version-of-java-on-osx
- rJava and OS X: https://support.rstudio.com/hc/communities/public/questions/200650933-rJava-fails-to-load-in-RStudio-Desktop-OS-X
- Java and Rstudio: https://support.rstudio.com/hc/en-us/community/posts/200650933-rJava-fails-to-load-in-RStudio-Desktop-OS-X
As Windows is by default installed for both 32 and 64 bit architectures, conflicts are usual. In order to adequately configure R and Java in Windows, the next steps should be followed:
- As both directories,
C:/Program Files
andC:/Program Files (x86)
exist, it may happen that R is looking for Java in one of them that does not hold the Java directory with a suitable Java version (see above). Then, it should match the R version we are running. - R (and RStudio if used) must work in the same architecture that the Java version. In RStudio, it is possible to set the R version in the Menu Tools --> Global options --> General
- The right
rJava
version matching the selected architecture should be installed. This can be checked by inspecting the existence of the directory x64 or i386 within the rJava folder created when installing the package, typically in something likeC:/Users/user/Documents/R/win-library/3.2/rJava
.
- Package Installation (and known problems)
- Model Data (reanalysis and climate projections)
- Observations (station and gridded data)
- Standard data manipulation