Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
  module load r/4.2.12

To make R 4.2.1 autoload on login

Code Block
  module initadd r/4.2.12

Interactive R use with slurm

...

Code Block
module purge
module load r/4.2.12
R
... # here will be the interactive commands with R
exit

Please, DO NOT FORGET to EXIT from the nodes so that the other users can use it.

Here is an alterative option to run an interactive R session with 24 cores using the “general” partition

To list available versions of R, type

Code Block
 srun -N 1 -n 128 -p general --constraint='epyc128' --pty bash

At the time of writing, the most up-to-date version installed on the cluster is 4.1.2. To load it, run

Code Block
  module purge
  module load r/4.2.2
  R
... # here will be the interactive commands with R
exit

Install an R package

Local package install

...

Info

You can use whichever name you prefer for the rlibs dir. It is important to make sure it is in your home directory though, so it becomes easier to access it from “different locations”.

...

Code Block
R
.libPaths("~/rlibs")
install.packages("data.table", lib = "~/rlibs", repo = "https://cloud.r-project.org/")

Note that:

  1. We need to specify the repo from which the packages will be downloaded from. For a list of options, take a look at https://cran.r-project.org/mirrors.html.

  2. We need to set lib when installing the package to tell R where to install it.

Now, whenever you start a new R session or use Rscript to run something, you will need to tell R that your packages are stored in the ~/rlibs directory. There are two ways to do it. In the first one, is to add

...

Code Block
echo '.libPaths("~/rlibs")' > .Rprofile
Info

Other A text editors editor (such as nano, vim, emacs, etc.) could have been used to create the .Rprofile file as well.

...