Information Technology
Running R on Ada

10-Apr-2007


Introduction

R is a language and environment for statistical computing and graphics. It is similar to the S language that was developed at Bell Laboratories. This document will describe how to run a very basic R job on Ada.


Running R with PBS

The steps for running R with PBS on Ada are described below:

1. Prepare the Data Directory

Create a directory to store your input and output data files. In this example, the input and output files and the PBS script will all be stored in the same directory. This is not required but is presented this way here to simplify the instructions. Start by creating a working directory called R, for example:


cd /home/adauser # go to your home directory
mkdir R # create a work directory named R

Create an R data file in this directory and call it Rdata.dat. Then create an R script input file called Rinput with contents such as the following:


load(file = "Rdata.dat")
... R script functions go here ...
save.image(file = "Rdata.dat")

2. Initialize your Environment to run R

In order to run R, you need to initialize your environment using the module command as follows:


module load R

This command will set the appropriate environment variables that you need to run R.

3. Prepare and Run the PBS Job

Once the data files are in place, create a PBS batch job script called R.pbs in the same directory with the following contents:


#PBS -N R #PBS -q compute #PBS -l nodes=1:ppn=1,walltime=04:00:00 #PBS -m abe #PBS -V ## this line is important
##to inherit the correct environment variables #PBS -M username@rice.edu
echo "My job ran on: "
cat $PBS_NODEFILE
cd $PBS_O_WORKDIR
R --vanilla < Rinput  > Routput   
                     ##this will run R with Rinput as the input script.

Now run the PBS job from this working directory as follows:


qsub ./R.pbs # this will submit the job to the job scheduler

More Information

For information about command line arguments for R, use the man R command. To view the user's guide, please see the R website.

 

IT
Division of Information Technology
MS-119, P.O. Box 1892, Rice University, Houston, Texas 77251-1892
713-348-HELP(4357)