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.3 | dec 14, 2015 | r/3.2.3 |
3.0.1 | aug 22, 2013 | r/3.0.1 |
2.15.3 | jul 22, 2013 | r/2.15.3 |
2.13.1 | aug 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 !"