R Guide

From Storrs HPC Wiki
Revision as of 17:27, 19 February 2016 by Cdk10001 (talk | contribs)
Jump to: navigation, search
R
Author Sandia National Labs and Temple University
Website https://www.r-project.org
Source CRAN
Category Statistics, Commandline utility
Help manual
mailing list
conferences


R is a GNU project for statistical computing and graphics. The R language is widely used among statisticians for developing statistical software and data analysis. See Wikipedia

There are several versions of R installed on the HPC Cluster. Users can install their own packages in their home directories.

Loading the R module

To list available versions of R, type

  module avail r

At the time of writing, version 3.11 contains the largest number of R packages which were installed per requests by users To load that module version for this session type (for example for 2.15)

  module load r/3.1.1

To make R autoload on login

  module initadd r/3.1.1

Install an R package

Local package install

Start an R session

R

Only for the purposes of installing a package, we make an exception for R run on a login node. In other cases, R processes will be killed if they are running with 100% CPU on the login node for more than 30 minutes.

If your module name is foo, run

install.packages('foo')

It will then output

Warning in install.packages("foo") :
 'lib = "/gpfs/gpfs1/apps/R/3.1.1/lib64/R/library"' is not writable
Would you like to create a personal library
~/R/x86_64-unknown-linux-gnu-library/3.1.1
to install packages into?  (y/n)

Enter y. If it exits with no errors, your local package installed successfully.

Global package install

Please submit a ticket with the packages you would like installed and the R version, and the administrators will install it for you.

Submitting an R batch job with Slurm

Assume that you have a script called helloworld.R with these contents:

cat('Hello world!')

Submit to Slurm scheduler using sbatch

 sbatch -n 1 R CMD BATCH helloworld.R

Submit to Slurm scheduler with multi-threading:

 sbatch -n 1 -c 20 --exclusive R CMD BATCH helloworld.R # use "-c 20" to setup multi-threading for R

When the job completes output will be written to helloworld.Rout