As an R user, you are likely very familiar with the example commands:

> install.packages("ggplot2")
> library(ggplot2)

or installing packages with Bioconductor.  Here are some notes regarding the installation of R packages.

A Note to Prior CentOS 6 MARCC Users

The use of R_LIBS_USER is deprecated, please rely on MARCC to generate local folders specific to R.

Previously, we recommended the use of setting R_LIBS_USER in your $HOME/.Renviron file.  The reason we don’t recommend it now is package collisions with varying versions of R.  Our new R modules will try to create appropriate directories in your home directories in the R folder. The first path listed in the R command .libPaths() should offer a local user library location first, then the system library location. We do install some tools in the system library, but we expect users to customize their packages and self-install packages fitting their needs.

Deprecated

R_LIBS_USER=~/Rpackages/

Installing R Packages

As a user, you should not need to worry about package management; the modules system should provide a suitable version of R without any extra effort.  But, we want to explain how we update folders to prevent collisions by installing R packages.

Currently, we support R/3.4.0 and R/3.5.1 under two compilers, Intel/18.0 and GCC/5.5.0; this means that we are actively supporting at least four combinations of R. There is even less work to do – the modules should try to take care of it for you.

Here’s a sampling of how working with these versions of R works:

# comment: start with the same recommended defaults by MARCC
module purge; module load MARCC 
# comment: take a look you will see at least two R versions
module avail
# comment: now load R
module load R
# comment: check R version
which R
# comment: result shows '/software/apps/R/3.5.1/intel/18.0/bin/R'
# comment: now launch R
R
> .libPaths()
[1] "$HOME/$USER/R/x86_64-pc-linux-gnu-library/3.5/intel/18.0"
[2] "/software/apps/R/3.5.1/intel/18.0/lib64/R/library"

At this point you should see a local home folder called Rin your $HOME.

Now, try this:

module load gcc/5.5.0 # R will reload because R is built there too
# comment: check R version
which R
# comment: result shows '/software/apps/R/3.5.1/gcc/5.5/bin/R'
# comment: now launch R
R
> .libPaths()
[1] "$HOME/$USER/R/x86_64-pc-linux-gnu-library/3.5/gcc/5.5"
[2] "/software/apps/R/3.5.1/gcc/5.5.0/lib64/R/library"

In many cases, R users will prefer the use of GCC compilers to ease installation of packages, if Intel/18.0 does not work, please load R using GCC 5.5.0 and try installing your packages again.

Tips for Modifying Files to Compile R Packages with Intel Compilers

MARCC users have reported that using GNU C++ 11 standard have allowed for their packages (such as “keras” and sub-dependent packages to compile).

$HOME/.R/Makevars

CC=icc -std=gnu11
CXX1XSTD = -std=c++0xi
CXX_STD = CXX11

After building packages, it may be easier to comment the flags back out (as they may not apply for all packages).