R

From ACENET
Jump to: navigation, search
Description
R is a freely available programming language and software environment for statistical computing and graphics, which provides a wide variety of statistical and graphical techniques: linear and nonlinear modelling, statistical tests, time series analysis, classification, clustering, etc.
Modulefile
r
Documentation
R homepage

Typical usage

At the command line:
$ module load r
$ R
Sample job script:
 #$ -cwd
 #$ -l h_rt=01:0:0
 #$ -j y

 module purge
 module load gcc r
 R --no-save -q < my_program.R

Installing Additional R packages

With the exception of the two discussed below, please install any R packages you need into your own home directory. Please select a Canadian mirror.

$ module load r
$ R
> install.packages(c("package_name1", "package_name2"), dependencies = TRUE)

Here is an example, using the rgl package:

> install.packages("rgl",configure.args="--disable-libpng")

Default version changed

The default version loaded with 'module load r' was changed from 2.13.1 to 3.1.2 on 2014 December 9. If you have packages installed and this changes breaks them, you have two options:

  1. Recommended: Reinstall the needed packages as above from the new version of R.
  2. Use 'module load r/2.13.1' to continue using the old release.

Once you've upgraded to the new version and tested that it works, your packages installed for 2.13 will be unneeded. You can free up disk space by deleting them. They're typically found in ~/R/x86_64-unknown-linux-gnu-library/2.13.

GDAL and rgdal

If you want to use GDAL with R, you need special instructions to install the corresponding R package rgdal. See the GDAL page.

Rmpi

Description
Rmpi is a package for R that allows parallel processing by providing an interface to MPI.
Documentation
Rmpi homepage
Modulefile
rmpi
Version
0.6-3, 0.6-5 depending on version of R
Usage
Rmpi is provided for R 2.14.2 and newer. In order to be able to use Rmpi properly, users are required to load the rmpi modulefile. If you can successfully load this modulefile, then your environment has been configured correctly. Loading the rmpi modulefile into your environment accomplishes two things:
  • A special file ~/.Rprofile is created in your home directory. This files contains necessary settings to integrate Rmpi with Grid Engine (read more here). If you already have ~/.Rprofile in your home directory, it will not be overwritten. If you want to ensure to that you got the right file, you may need to remove the existing one and then reload the rmpi modulefile.
  • It ensures that you have loaded the appropriate Open MPI library.
IMPORTANT
The corresponding cluster of processes is already pre-constructed with mpirun. You do not need to launch any processes from within your R script.
Here is an example of a submission script for a job using Rmpi:
#$ -cwd
#$ -l h_rt=01:00:00
#$ -pe ompi* 4

module purge
module load gcc openmpi/gcc r rmpi

mpirun R --no-save -q < demo-rmpi.R
Here is the R code demo-rmpi.R demonstrating Rmpi:
# The corresponding cluster of processes is already pre-constructed with mpirun.

# This where the main work happens
mpi.remote.exec(paste("Rank",mpi.comm.rank(),"on",Sys.info()[c("nodename")]))

# Shut down the cluster and clean up any remaining connections between machines.
mpi.close.Rslaves()
mpi.quit()

Snow

Description
The package snow (an acronym for Simple Network Of Workstations) provides a high-level interface for using a workstation cluster for parallel computations in R.
Documentation
snow homepage
Version
0.3-12, 0.3-13, 0.4-1 depending on version of R
Modulefile
snow
Usage
Snow is provided for R 2.14.2 and newer. In order to be able to use snow properly, users are required to load the snow modulefile. If you can successfully load this modulefile, then your environment has been configured correctly. Loading the snow modulefile into your environment accomplishes two things:
  • A special file ~/.Rprofile is created in your home directory. This files contains necessary settings to integrate snow with Grid Engine. If you already have ~/.Rprofile in your home directory, it will not be overwritten. If you want to ensure to that you got the right file, you may need to remove the existing one and then reload the snow modulefile.
  • It ensures that you have loaded the appropriate Open MPI library.
IMPORTANT
The corresponding cluster of processes is already pre-constructed with mpirun. You do not need to launch any processes from within your R script.
Here is an example of a submission script for a job using snow:
#$ -cwd
#$ -l h_rt=01:00:00
#$ -pe ompi* 4

module purge
module load gcc openmpi/gcc r snow

mpirun R --no-save -q < demo-snow.R

And here is an example of how demo-snow.R can utilizes snow:
# The corresponding cluster of processes is already preconstructed with mpirun.
# You can use either command below with no arguments to get the pre-constructed cluster.
cl <- getMPIcluster()
# cl <- makeCluster()

# This where the main work happens
clusterCall(cl, function() Sys.info()[c("nodename")])

# Shut down the cluster and clean up any remaining connections between machines.
stopCluster(cl)