BwUniCluster2.0/Software/R: Difference between revisions

From bwHPC Wiki
Jump to navigation Jump to search
No edit summary
Line 131: Line 131:
</pre>
</pre>


== Installing R-Modules into your home folder ==
== Installing R-Packages into your home folder ==


Since we cannot provide an software module for every R package we recommend to install special R packages locally into you home folder. One possibility how to do this is shown below.
Since we cannot provide a software module for every R package we recommend to install special R packages locally into your home folder. One possibility doing this is shown below:


<pre>
<pre>
Line 143: Line 143:
$ R
$ R
$ install.packages('package_name', repos="http://cran.r-project.org")
$ install.packages('package_name', repos="http://cran.r-project.org")
library(package_name)
</pre>
</pre>

The package is now installed permanently in your home folder and is available every time you start R.


You can restore your old .bashrc if something goes wrong with:
You can restore your old .bashrc if something goes wrong with:
Line 149: Line 152:
mv $HOME/.bashrc.backup $HOME/.bashrc
mv $HOME/.bashrc.backup $HOME/.bashrc
</pre>
</pre>

Installed packages can be deleted by deleting the folder ${HOME}/R_libs.


== Version-Specific Information ==
== Version-Specific Information ==

Revision as of 17:22, 27 July 2015

R
module load math/R
Availability bwUniCluster
License GPL
Citing
Links Homepage; Documentation
Graphical Interface No
Included in module


Description

R is a language and environment for statistical computing and graphics. It is a GNU project which is similar to the S language and environment which was developed at Bell Laboratories (formerly AT&T, now Lucent Technologies) by John Chambers and colleagues. R can be considered as a different implementation of S. There are some important differences, but much code written for S runs unaltered under R.

R provides a wide variety of statistical (linear and nonlinear modelling, classical statistical tests, time-series analysis, classification, clustering, …) and graphical techniques, and is highly extensible. The S language is often the vehicle of choice for research in statistical methodology, and R provides an Open Source route to participation in that activity.

One of R’s strengths is the ease with which well-designed publication-quality plots can be produced, including mathematical symbols and formulae where needed. Great care has been taken over the defaults for the minor design choices in graphics, but the user retains full control.

R is available as Free Software under the terms of the Free Software Foundation’s GNU General Public License in source code form. It compiles and runs on a wide variety of UNIX platforms and similar systems (including FreeBSD and Linux), Windows and MacOS.


Versions and Availability

A current list of the versions available on the bwUniCluster and bwForClusters can be obtained from the Cluster Information System: CIS Information on R

On the command line interface of any bwHPC cluster, a list of the available R versions using

$ module avail math/R


Usage

The R installation also provides the standalone library libRmath. This library allows you to access R routines from your own C or C++ programs (see section 9 of the 'R Installation and Administration' manual.)


Loading the module

You can load the default version of R with the command

$ module load math/R

The module will try to load modules it needs to function (e.g. compiler/intel). If loading the module fails, check if you have already loaded one of those modules, but not in the version needed for R.

If you wish to load a specific (older) version, you can do so using e.g.

$ module load math/R/3.1.2

to load the version 3.1.2.


Program Binaries

Standard usage:

Usage: R [options] [< infile] [> outfile]
    R CMD command [arguments]
  
Example: R CMD BATCH script.R

Executing R in batch mode:

R CMD BATCH --no-save --no-restore <INPUT_FILE>.R

For help run

R --help

For command help run

R CMD command --help

Further informations and herlp_

Man pages:          'man R' and 'man Rscript'
Info pages. e.g.:   'info R-intro' or 'info R-FAQ'
Manuals:               $R_DOC_DIR/manual


Examples

As with all processes that require more than a few minutes to run, non-trivial compute jobs must be submitted to the cluster queuing system.

Example scripts are available in the directory $R_EXA_DIR:

$ module show math/R                                                                  # show environment variables, which will be available after 'module load'
$ module load math/R                                                                    # load module
$ ls $R_EXA_DIR                                                                           # show content of directory $R_EXA_DIR
$ cat $R_EXA_DIR/README                                                          # show examples README

Run a first simple example job

$ module load math/R                                                                     # load module
$ mkdir Rtest                                                                                  # create test directory
$ cp $R_EXA_DIR/bwhpc-r.moab $R_EXA_DIR/fit.R Rtest/          # copy example files to test directory
$ cd Rtest/                                                                                     # change to directory
$ nano bwhpc-r.moab                                                                    # change job options, quit with 'CTRL+X'
$ msub bwhpc-r.moab                                                                   # submit job
$ checkjob -v <JOBID>                                                                   # check state of job
$ ls                                                                                                  # when job finishes the results will be visible in this directory

Installing R-Packages into your home folder

Since we cannot provide a software module for every R package we recommend to install special R packages locally into your home folder. One possibility doing this is shown below:

$ cp $HOME/.bashrc $HOME/.bashrc.backup
$ echo "export R_LIBS=\"${HOME}/R_libs\"" >> $HOME/.bashrc
$ source $HOME/.bashrc
$ mkdir $R_LIBS
$ module load math/R
$ R
$ install.packages('package_name', repos="http://cran.r-project.org")
library(package_name)

The package is now installed permanently in your home folder and is available every time you start R.

You can restore your old .bashrc if something goes wrong with:

mv $HOME/.bashrc.backup $HOME/.bashrc

Installed packages can be deleted by deleting the folder ${HOME}/R_libs.

Version-Specific Information

For information specific to a single version, see the information available via the module system with the command

$ module help math/R