R is an interpreted computer language for statistical computing and graphics including: linear and generalised linear models, non-linear regression models, time series analysis, classical parametric and non-parametric tests.
For efficiency, procedures written in the C, C++, or FORTRAN languages may be interfaced within R in addition to the user-visible R functions.
R is available as a module on Apocrita.
To run the latest installed version of R, simply load the
$ module load R $ R --help Usage: R [options] [< infile] [> outfile] or: R CMD command [arguments] $ Rscript --help Usage: /path/to/Rscript [--options] [-e expr [-e expr2 ...] | file] [args]
For further usage documentation, see the full output of
R --help or the
man R and
R can be executed through the 'R CMD' interactive interface using
R or via
Rscript non-interactive interface. The
Rscript binary provides an
alternative front end to the legacy
R CMD BATCH method to run R commands
in a non-interactive shell.
Do not use
detectCores() is not cluster aware and will incorrectly return all cores
on a machine even if they are not actually available.
The documentation for R covers this:
"This is not suitable for use directly for ... specifying the number of cores in
First because it may return NA, second because it does not give the number of allowed cores"
We advise specifying the number of cores directly:
cluster <- makeCluster(4)
Here is an example job running on 2 cores and 4GB total memory:
#!/bin/bash #$ -cwd #$ -j y #$ -pe smp 2 #$ -l h_rt=1:0:0 #$ -l h_vmem=2G module load R Rscript myscript.R
Rscript within Apocrita jobs
When running R jobs on Apocrita, use
Rscript to submit a file containing
R commands; R output will be written to the
Additional R Packages¶
Additional packages can be installed to extend the capabilities of R; Packages are stored in libraries.
- To display the list of active libraries, execute:
> .libPaths()  "/share/apps/centos7/R/<VERSION>/lib64/R/library"
- To display the list of currently loaded packages (including default packages), execute:
> (.packages())  "stats" "graphics" "grDevices" "utils" "datasets" "methods"  "base"
- To display all packages available in the currently loaded libraries, execute:
> .packages(all.available = TRUE)  "base" "boot" "class" "cluster" "codetools"  "compiler" "datasets" "foreign" "graphics" "grDevices" ...
- To install additional R packages, execute:
Packages which are not included in the R main library will be added to the personal library.
Creating a personal library
If a personal library has not already been created, respond with
prompted to create and use a personal library. Also select your closest
Secure CRAN mirror.
- To load an R package, execute:
- To find the location where a package is installed, execute:
> find.package("<package_name>")  "/path/to/package"
We have created a module
gdal in order to support some R users who wanted
to build the
rgdal package. If you load this before starting your R
session you should be able to build
Bioinformatics packages for R¶
Bioinformatics packages for R can be installed with the bioconductor script and then loaded like a normal R package by executing the following commands:
source("https://bioconductor.org/biocLite.R") biocLite("<package_name>") library("<package_name>")