R is a free software environment for statistical computing and graphics. More information is available at the R project website.

Running R

R can be run in both interactive and batch modes. To begin using R, the path to executables and other path variables need to be set.All required environment variables can be set by loading the R module, to do this issue:

$ module add R


Running through an interactive shell

The following will launch R interactively via the batch queues.

$ qrsh -cwd -V -l h_rt=<hh:mm:ss> R <option>

In the above command, <hh:mm:ss> is the length of real-time the shell will exist for. eg to run R for 6 hours:

% qrsh -cwd -V -l h_rt=6:00:00 R <option>

Please note that <option> must be set to one of --save--no-save or --vanilla. This will run R from within the terminal from which it was launched.

Batch Execution

To run R in batch-mode, first generate a file with a list of commands for R to process, eg r.in. A script must then be created that will request resources from the queuing system and launch the R executable, eg runR.sh:

# Run in current working directory and use current environment
#$ -cwd -V
# Set a 6 hour limit
#$ -l h_rt=6:00:00
#Request more memory, the default is 1Gb
#$ -l h_vmem=2G
# Load R module
module add R
# run R using command file
# CMD BATCH flag should be given to suppress graphics
R CMD BATCH r.in r.out

This can be submitted to the queuing system using:

$ qsub runR.sh


Installing R packages

Given the large number of R packages available and pace of development, it is preferable that users install the packages they need as opposed to using a centrally provided set of packages. To install package foo, start an R session by entering its name on the Polaris command prompt:

$ R

and then from within R, install the package:


This will install the package and any dependencies that are required, in a directory of your choice. The package should then be accessible from subsequent R interactive sessions and batch jobs, by loading the packages from the appropriate directory.

Licensing information

R is free software available under the GNU General Public License.