R and packages

You can, or will have to, install complementary packages in R.

First, create a directory (ex: for R 4.0.4):

mylogin@x5570comp2:~$ mkdir lib_R_4.0.4

Then, edit your ~/.profile to add a line like this:

export R_LIBS="/home/mylogin/lib_R_4.0.4":$R_LIBS

Important

Yes, you need to change mylogin by your login at PSMN, and lib_R_4.0.4 by the one you’ve just created.

Source your ~/.profile for it to be taken into account right away (or disconnect/reconnect):

source ~/.profile

Verify by loading R, and use .libPaths():

mylogin@x5570comp2:~$ R

R version 4.0.4 (2021-02-15) -- "Lost Library Book"
[...]

> .libPaths()
[1] "/home/mylogin/lib_R_4.0.4"    "/usr/local/lib/R/site-library"
[3] "/usr/lib/R/site-library"       "/usr/lib/R/library"
>

Now, you can install packages for R, the usual way, while specifying path:

install.packages("zoo", lib="/home/mylogin/lib_R_4.0.4")

Same way, personal packages can be used:

library(zoo)
# or
library(zoo, lib.loc="/home/mylogin/lib_R_4.0.4")

Same can be done with group or teams packages (see Where to store files?). You can also have multiples directories for different workflows.