What is R?

R is a programming language and software environment for statistical computing and graphics. It is similar to the S language and R can be considered as a different implementation of S.

The capabilities of R are extended through user-created packages, which allow specialized statistical techniques, graphical devices (ggplot2), import/export capabilities, reporting tools, etc. R Packages including snow, Rmpi, snow, doMPI are installed in our HPC system for parallel computation. The Bioconductor project provides many additional R packages for statistical data analysis in different life science areas, such as tools for microarray, next generation sequence and genome analysis.

Using R in HPC system

To setup required environment variables for R, please use following command:

System R version Command
HPC2015 3.2.2 module load R/3.2.2
3.2.5 module load R/3.2.5
3.4.1 module load R/3.4.1
3.5.1 module load R/3.5.1
3.6.1 module load R/3.6.1
4.0.1 module load R/4.0.1
HPC2021 4.0.4 module load R/4.0.4
4.1.2 module load R/4.1.2

To debug R interactively, type “R“. To quit the R environment, type “q()” in the R prompt.

Interactive process that executes over 15 minutes would be killed automatically. User are advised to run R in batch mode by submitting job to the PBS queuing system with follow command.

To run R in batch mode:

R --no-save < INPUT_FILE > OUTPUT_FILE   or  R --slave < INPUT_FILE > OUTPUT_FILE

Sample PBS/SLURM command file for serial R program is provided at /share1/R/sample/ .

Run parallel R jobs

We prepared some sample R programs and PBS/SLURM command file to demonstrate how to run parallel R jobs in cluster systems. User can obtain these files at /share1/R/sample/.

R Packages

Usually R libraries/add-on packages of common interests are available to all users. User could find out the lists of additional packages available on the system by issue the command:

library()

If you want to find out whether a specific R package is installed, type:

find.package(package = "pkg")

You can then find out which functions it provides by typing either

library(help = pkg)  or   help(package = pkg)

Install R Libraries locally in home directory

In some cases, you may want to quickly test some packages and want to install the library locally. To install add-on package under your home directory, you can:

  1. Create a directory in your home directory and set variable to point R to that directory
    mkdir -p ~/R_libs/4.0.4 
    
    • Method 1: Download the source file of required add-on R package (.tar.gz file) from CRAN website. Install the downloaded package by command:
      module load R/4.0.4
      R CMD INSTALL -l ~/R_libs/4.0.4 pkg_version.tar.gz
    • Method 2: Type the following commands inside R prompt:
      > install.packages("lattice", repos="http://cran.r-project.org")
      

 

To check the directories that R searches for libraries, in the R prompt you can type:

.libPaths();

Once you try out the package and find it may be useful for other users, please contact the system administrator to install the package globally so that all users can use it.

Additional Information

Official site of R Project: http://www.r-project.org/
An Introduction to R
The R Manuals
High Performance and Parallel Computing with R