-
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. A slightly modified version of this open source software (v4.6-SNAPSHOT) is automatically linked when loading the package. This is done by the dependency package loadeR.java, that performs the internal operations to initialize the Java Virtual Machine and the netCDF-Java API. The connection between R and Java is established through the rJava package, providing a low-level interface to Java from R. Thus, this package is a dependency of loadeR
.
(1) Install the rJava
package available on CRAN. See the information below if you find problems in this step.
(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).
For instance, a typical setting for ‘x86_64’ Linux is
JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.51-4.b16.fc21.x86_64/jre
Or for Windows:
JAVA_HOME=C:\\Program Files (x86)\\Java\jdk1.7.0\\jre
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
, as follows (for instance a typical Windows path):
Sys.setenv(JAVA_HOME = "C:\\Program Files (x86)\\Java\jdk1.7.0\\jre")
or forcing the removal of the current JAVA_HOME:
Sys.setenv(JAVA_HOME = "")
After this, it is necessary to run R CMD javareconf
from a terminal to update the settings (this requires superuser privileges in Linux, or alternatively running ~$ R CMD javareconf -e
).
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-get install or similar (instructions for different Linux distributions can be seen in this link):
~$ sudo apt-get install r-cran-rjava
Mac OS X comes with a preinstalled old Java version (1.6). 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). This can be sometimes solves by opening R (or RStudio) from the terminal instead of directly clicking on the application icon
~$ R
or
~$ /Applications/RStudio.app/Contents/MacOS/RStudio
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