R

R is used for statistical computing.

Libraries

Optimised builds of R are installed on ALICE and SPECTRE with a large number of extra libraries, including many from Bioconductor.

You can see the list of currently installed libraries by running this command:

R -q -e 'installed.packages()'

You can install additional libraries in your home directory. If you want additional libraries installed centrally, contact the IT Service Desk.

Example submission script

Full submission script for an example R script example.R:

#!/bin/bash

#PBS -N R_Job
#PBS -l walltime=01:00:00
#PBS -l nodes=1:ppn=1
#PBS -l vmem=4gb

module load R/3.3.1

cd $PBS_O_WORKDIR

R --no-save -q -f example.R

If you are going to run multiple copies of R at the same time you may need to disable use of the workspace file, this can be done using the --vanilla flag, e.g.

#!/bin/bash

#PBS -N R_Job
#PBS -l walltime=01:00:00
#PBS -l nodes=1:ppn=1
#PBS -l vmem=4gb

module load R/3.3.1

cd $PBS_O_WORKDIR

R CMD BATCH --vanilla -q example.R

Rmpi

Rmpi is a library which implements the MPI scheme in R. You can use this library in two ways: on its own, or further abstracted with the snow library.

Rmpi on its own

To use Rmpi on its own (i.e. not with snow), use a submission script such as the following. Note that the Rmpi Rprofile file should be used, and you need to start the R job with mpiexec.

#!/bin/bash

#PBS -N Rmpi
#PBS -l walltime=01:00:00
#PBS -l nodes=3:ppn=8
#PBS -l vmem=4gb

module load R/3.3.1
# The OpenMPI module provides the mpiexec command
module load openmpi/gcc/2.0.2

# The Rmpi Rprofile file should be used
export R_PROFILE=$RMPI_RPROFILE

mpiexec R --no-save -q -f rmpi_example.R

Rmpi with snow

The snow library abstracts the parallelisation of R with MPI and takes care of spawning processes. Although snow jobs require Rmpi, jobs submitted using snow should not use the Rmpi Rprofile file, and should launch with mpiexec with only a single task. Snow will work out how many sub-processes to spawn itself. Example submission script:

#!/bin/bash

#PBS -N SNOW
#PBS -l walltime=01:00:00
#PBS -l nodes=3:ppn=8
#PBS -l vmem=4gb

module load R/3.3.1
# The OpenMPI module provides the mpiexec command
module load openmpi/gcc/2.0.2

# For snow jobs, use 'mpiexec -n 1'
mpiexec -n 1 R --no-save -q -f snow_example.R

Share this page: