R is a software environment for statistical computing and graphics.

Category:  Bioinformatics/Statistics

Availability: Open access for all academic users



Usage Notes

To show the software versions:  module avail R

Loading the module will set the path and any necessary variables:  module load R/version

Rmpi, an interface to MPI (Message-Passing Interface), is available with versions of R 2.11.1 and greater.  Sample SLURM scripts and examples are in the /util/academic/R directory - subdirectories: Rmpi-example, Rmpi-simple, and Rmpi-julia.


R manuals can be found here



Additional Information

Numerous add-on packages for R have been installed in many of the CCR R installations; however, they may vary by version. A complete list for a given version may be viewed using the following command, after loading your preferred R version using the 'module load' command:


cat $R_DIR/PkgList.txt



To install an R package in user (or projects) space:


Nearly 20,000 packages are available for R.  If you want to use a package for R that is not already installed, you can install your own packages by either downloading the package and installing it or pointing to the R package library and installing directly from there.  The two options are shown below.  To see the full list of R packages available, please visit the R project page: 

 https://cran.r-project.org/


Option 1: Download and install R packages in your home or project directory


Download the R package you want to install.  In this example, we demonstrate the 'readr' package:

 wget https://cran.r-project.org/src/contrib/readr_2.0.2.tar.gz


Create your R library directory in your home or project directory, if you don't have one already.  For example:

mkdir /user/[username]/rlibs

or

mkdir /projects/[academic/industry]/[groupname]/[username]/rlibs


Then point to that directory when installing the R library you want to use:

R CMD INSTALL -l /user/[username]/rlibs package


For our example, to install the readr package we got with the wget command:

R CMD INSTALL -l /user/[username]/rlibs readr_2.0.2.tar.gz


Option 2: Install directly from the R Project repository from within R:


Load your preferred version of R and launch R:

module load R/version

R


Then install the package by specifying the package name, R project repository, and your R library location in your home or project directory


install.packages("package_name", repos = "http://cran.r-project.org", lib = "/user/[username]/rlibs")


For our example, to install the readr package:

install.packages("readr", repos = "http://cran.r-project.org", lib = "/user/[username]/rlibs")



To load an R package from user (or projects) space:


module load R

R
library(package, lib.loc="/user/[username]/rlibs/")


For our example, this would be:

library(readr, lib.loc="/user/username]/rlibs/")