R

R is a system for statistical computation and graphics. It consists of a language plus a run-time environment with graphics, a debugger, access to certain system functions, and the ability to run programs stored in script files.

The design of R has been heavily influenced by two existing languages: Becker, Chambers & Wilks' S and Sussman's Scheme. Whereas the resulting language is very similar in appearance to S, the underlying implementation and semantics are derived from Scheme.

See the R website for more details.

Availability on Wesley

  Version    Date Installed    Setup Module  
3.2.3Dec 14, 2015R/3.2.3
3.0.1Aug 22, 2013R/3.0.1
2.15.3Jul 22, 2013R/2.15.3
2.13.1Aug 12, 2011*none*

IMPORTANT: If you do not load any R module then you will get the oldest version 2.13.1.

To use the newest version that is installed, load the R module without specifying a version:

module load R

To use a specific version, include it when you load the module. For example,

module load R/2.15.3

Note: if you used R before Wesley began using Modules to manage software then you may have R explicitly added to your PATH in one or more of your .bashrc, .bash_profile, .cshrc or .login files in your home directory. These references to R should be removed so they do not interfere with the above module commands.

Running R Interactively on the headnode

After the module is loaded you can start an interactive R session by entering the command:

R

Please limit your interactive use of R on the headnode to small cases only (no more than 1gb of RAM and no more than 1 hour of CPU time).

Submitting batch jobs to the queue to be run on compute nodes

The following "Hello World" example demonstrates one way to submit an R program.

Create a file named hello.r containing the following R program.

a <- c("Hello", "world", "!")
print(a)
b <- paste(a, collapse = " ")
print(b)

Create a Torque/PBS job script. In this example we will name it myRjob.qsub:

#!/bin/bash -l

# load the latest version or R
module load R

# go to the directory where the qsub command was invoked from.
cd $PBS_O_WORKDIR

# run the job
Rscript hello.r

Submit this job to the queue with the following qsub command:

qsub -l nodes=1:ppn=1,walltime=2:30:00 myRjob.qsub

Note: The walltime=2:30:00 tells the queueing system that this job should only be allowed to run for a maximum of 2 hours and 30 minutes, after which it should be automatically killed. Be sure to adjust your walltime appropriately.

When the job completes you should have two output files. One named myRjob.qsub.oJOBID and one named myRjob.qsub.eJOBID. The first is the normal output from the R program. The second will contain any error's that might have occurred. The myRjob.qsub.oJOBID file from the hello world example should look like:

[1] "Hello" "world" "!"
[1] "Hello world !"