R and Rscript¶
Various versions of the R environment are available on CSD3. The latest
versions are r/4.1.3/gcc/intel-oneapi-mkl/7dubq4gn
(GTK library support), r/4.1.3/gcc/intel-oneapi-mkl/wwmppxe3
(vanilla) on the icelake
partition and r/4.4.0/gcc/3z5n2tph
on the cclake
partition.
R can be run interactively by simply calling R
, which will give a standard
R shell. This can be used for testing or setting up larger runs. However for
use inside the job scheduler it will generally be more effective to record the
R script in a file analysis.R
and call it from inside a slurm batch script
Rscript analysis.R
. For more examples of how to use slurm and write an
appropriate batch script please see Running.
Installing R packages¶
While a few R packages have been centrally installed on CSD3 (do module avail r-
to see a list), it is often necessary to install extra R packages into your own environment. For example to install cellranger, one can use:
$ R
R version...
[...]
> install.packages("cellranger")
which will download and build the package from CRAN.
If you run into build errors, the first fix is to tell R where to find the correct compiler. This can be done by creating the file ~/.R/Makevars
in your home directory and adding:
CC = gcc
CXX = g++
CXX11 = g++
FC = gfortran
F77 = gfortran
F90 = gfortran
which tells R to use the system compilers. If you run into problems with the compiler versions being too old, then try loading a more recent compiler before starting R. If you run into problems that refer to the C or C++ standard versions then try adding:
CFLAGS = -std=c99
CXXFLAGS = -std=c++11
to ~/.R/Makevars
.