Working with R
R module and version
We are currently using the R/4.3.1-foss-2022b-bare-noSciPy module as our default.
This module provides R 4.3.1 built with the foss-2022b toolchain with only the base package set. This avoids conflict/confusion between centrally installed libraries and user-installed libraries.
R configuration
A minimal .Rprofile file is provided in dotfiles/Rprofile:
# Set the R package location # (make sure to edit to your own $USER name!) .libPaths(c("/well/sansom/users/$USER/devel/R/4.3/skylake/")) # Set a local mirror for packages options(repos=structure(c(CRAN="https://www.stats.bris.ac.uk/R/"))) # Set cairo as the default bitmap type options(bitmapType='cairo') # Optional - Enable vscode hooks # if (interactive() && Sys.getenv("RSTUDIO") == "") { # source(file.path(Sys.getenv(if (.Platform$OS.type == "windows") "USERPROFILE" else "HOME"), ".vscode-R", "init.R")) # } # End line to ensure that the last command as a new line (else it is not executed!)
Note
If necessary, create the directory specified in the Rprofile .libPaths() function before atttempting to install packages.
Note
This setup assumes that you will use R only on the skylake nodes. It is different from the set up recommended by the BMRC which performs automatic CPU architecture detection and uses multiple package libraries for different architectures. In the group we prefer to be explicit about the location of the R libraries so that (i) we know which code we are using to perform analysis (important for reproducibility) and (ii) we only install packages once.
Warning
R libraries compiled on skylake will not run on ivybridge nodes. If you need to use ivybridge nodes, you can maintain a seperate pacakage library and switch .libPaths() statements as needed. TODO: investigate use of renv.