R and Rscript¶
Various versions of the R environment are available on CSD3. The latest
version, R 3.5.2 is available either as
r-3.5.2-gcc-5.4.0-jqs2rxd. The former is a vanilla R install with no
special options, whereas the latter is linked against the linear algebra
library openblas and may provide substantially better performance.
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