NERSCPowering Scientific Discovery Since 1974


Description and Overview

R is a language and environment for statistical computing and graphics. It provides a wide variety of statistical tools, such as linear and nonlinear modelling, classical statistical tests, time-series analysis, classification, clustering, graphics, and it is highly extensible.

R provides an Open Source route to express statistical methodologies, it is a GNU project with similarities to the S language and environment. One of R's strengths is the ease with which well-designed publication-quality plots can be produced, including mathematical symbols and formulae where needed. R is an integrated suite of software facilities for data manipulation, calculation and graphical display. 

R users should also be interested in the RStudio web integrated development environment hosted at NERSC.

How to Use R

R is available at NERSC on Carver, Hopper, and Edison.  There are theoretically no limitations to the number of R sessions running at NERSC. Type the following command to launch R:

%module load R 

 To run R interactively,

% salloc -q interactive -t 30:00
% module load R
% R

To run R non-interactively through a batch job, you can create the following job script, e.g.

#!/bin/bash -l
#SBATCH -J R_test
#SBATCH -N 1 -t 2:00:00
#SBATCH -q regular

module load R

where, for example, code.R could be:

imagfilename = paste('myimag', j ,'.pdf',sep='');
pdf(file=imagfilename, width = 800, height =800)
plot(x, main='R is fun')

In order to run your jobscript, 


On Cori, you will need to also specify the hardware class (e.g. -C haswell).

How to Run R in Parallel

The following program illustrates how R can be used for 'coarse-grained parallelization', particularly useful when chunks of the computation are unrelated and do not need to communicate in any way. The example below uses the package parallel to create workers as lightweight processes via forking, and are very useful to optimize codes that use lapply, sapply, apply and related functions:

f = function(x) { sum = 0 for (i in seq(1,x)) sum = sum + i return(sum) } n=1000 nCores <- detectCores() result = mclapply(X=1:n, FUN = f, mc.cores=nCores)


Extensive on-line documentation is available. You may subscribe to the one or more of R Mailing lists. Also, find a quick R tutorial presented at one of our Nersc User Group Meetings.


PackagePlatformCategoryVersionModuleInstall DateDate Made Default
R cori applications/ visualization 3.3.1 R/3.3.1 2016-06-29 2016-06-29
R cori applications/ visualization 3.3.2 R/3.3.2 2017-01-06
R cori applications/ visualization 3.4.0 R/3.4.0 2018-02-14
R davinci applications/ math 2.11.1 R 2010-08-10 2010-08-10
R edison applications/ visualization 3.3.1 R/3.3.1 2017-08-10
R edison applications/ visualization 3.3.2 R/3.3.2 2017-08-10 2017-08-10
R genepool applications/ programming 2.12.0 R/2.12.0 2012-04-02
R genepool applications/ programming 2.14.1 R/2.14.1 2012-04-02 2012-04-02
R genepool applications/ programming 2.15.0 R/2.15.0 2012-05-14 2012-05-14
R genepool applications/ programming 2.15.1 R/2.15.1 2012-07-07
R genepool applications/ programming 2.15.2 R/2.15.2 2012-11-09 2012-12-18
R genepool applications/ programming 2.15.2_1 R/2.15.2_1 2013-01-28 2013-01-28
R genepool applications/ programming 2.2.26 ncbi/2.2.26 2012-05-14 2012-05-14
R genepool applications/ programming 3.0.1 R/3.0.1 2013-06-08 2013-06-18
R genepool applications/ programming 3.1.1 R/3.1.1 2014-07-25
R genepool applications/ programming 3.1.2 R/3.1.2 2015-02-20
R genepool applications/ programming 3.2.1 R/3.2.1 2015-06-30
R genepool applications/ programming 3.2.2 R/3.2.2 2015-11-06
R genepool applications/ programming 3.2.4 R/3.2.4 2016-03-16
R genepool applications/ programming 3.3.1 R/3.3.1 2016-07-07
R genepool_sl6 applications/ programming 3.0.1 R/3.0.1 2016-03-08
R genepool_sl6 applications/ programming 3.1.2 R/3.1.2 2015-03-06 2015-03-06
R genepool_sl6 applications/ programming 3.1.3 R/3.1.3 2015-03-25
R genepool_sl6 applications/ programming 3.2.5 R/3.2.5 2016-10-06
R genepool_sl72 applications/ programming 3.3.2 R/3.3.2 2017-01-31
R phoebe applications/ programming 2.15.1 R/2.15.1 2013-06-26
R phoebe applications/ programming 2.15.2 R/2.15.2 2013-06-26
R phoebe applications/ programming 2.15.2_1 R/2.15.2_1 2013-06-26
R phoebe applications/ programming 3.0.1 R/3.0.1 2013-06-26 2013-06-26