Installing R packages on CLA Linux Compute Servers

Installing R packages

The R builds on the CLA linux compute servers are configured to allow users to install R packages in their home directory. The packages will be installed in ~/.libraries/R/$R_version/library where $R_version is the major and minor number of the version of R that you are using. For example, if you loaded the R/3.5.1 modulefile, user-installed packages will be installed in ~/.libraries/R/3.5/library. (Information on loading modules can be found on our page for using modules.)

To install a package, you will first need to load the modulefile for the version of R that you want to use and then open R or RStudio.

module load R/3.5.1
OpenMPI 2.1.6 using GCC 4.8.5: loaded
R 3.5.1: loaded
R

You can then install packages as normal in R/RStudio:

> install.packages("snow")
> Installing package into '/home/goldy/.libraries/R/3.5/library'
(as 'lib' is unspecified)
 

Note: If you are installing packages using a script and haven't previously installed packages for the particular version of R that your script is using, you will need to manually install a package first in order to create the library. After that, you will be able to install additional packages from your script.

 

Special notes for certain R packages

Some packages are more difficult to install due to various dependencies issues and other package requirements. To make it easier for our users to install these packages, we have added some customizations to the R environment on our CLA Linux compute servers. Please be aware that, while some packages may install easily without error on the CLA Linix compute servers, installing them elsewhere, such as a server in another department, may require a few extra steps. We have documented those steps here for those users that may need them.

Rmpi

Installing Rmpi on the CLA Linux comput servers

To install the Rmpi package on the CLA Linux compute servers, use the pacman::p_load(Rmpi) command. The 'install.packages("Rmpi") command will also work, though the pacman command is preferred.

module load R/3.5.1
OpenMPI 2.1.6 using GCC 4.8.5: loaded
R 3.5.1: loaded
R
> pacman::p_load(Rmpi)
> Installing package into '/home/goldy/.libraries/R/3.5/library'
(as 'lib' is unspecified)

Installing Rmpi on non-CLA Linux compute servers

To install Rmpi on a non-CLA Linux compute server, you will need to specify some config args to tell Rmpi where the OpenMPI libraries and header files can be found. Most HPC systems where you would use Rmpi should have the OpenMPI packages installed. The location of the library and header files will vary depending on the Linux distrbution that the server is running. Follow the instructions for your Linux distribtion below.

RedHat/CentOS

First, you will need to set your LD_LIBRARY_PATH:

export LD_LIBRARY_PATH=/usr/lib64/openmpi/lib/:${LD_LIBRARY_PATH}

Then start R and install Rmpi:

R
> install.packages("Rmpi", configure.args =
+    c("--with-Rmpi-include=/usr/include/openmpi-x86_64/",
+       "--with-Rmpi-libpath=/usr/lib64/openmpi/lib/",
+       "--with-Rmpi-type=OPENMPI"))

Ubuntu/Debian

You shouldn't need to set the LD_LIBRARY_PATH. Just start R and install Rmpi:

R
> install.packages("Rmpi", configure.args =
+    c("--with-Rmpi-include=/usr/lib/openmpi/include/",
+       "--with-Rmpi-libpath=/usr/lib/openmpi/lib/",
+       "--with-Rmpi-type=OPENMPI"))