I am setting up a cluster where all nodes have access to /nfs/software
, so a good place to install.packages()
would be under /nfs/software/R
. How do I set R_LIBS_SITE
so that this is automatically part of all users' R environment? I tried prepending to the path given for R_LIBS_SITE in /etc/R/Renviron
but help(Startup)
says "do not change ‘R_HOME/etc/Renviron’ itself", which I'm not sure is the same file since R_HOME
expands to /usr/lib/R
, but has no effect in any case. Making entries in the various Renviron.site
and Rprofile.site
files does not seem to have the desired effect. What am I missing here?
Some other questions have danced around this (here and here, maybe others), but people seem to settle for having a user-specific library in their HOME
.
Make sure you have owner and/or group write permissions for the directory you want to write into.
The file
/etc/R/Renviron.site
is the preferred choice for local overrides to/etc/R/Renviron
.Another way is to simply ... impose the directory when installing packages. I tend to do that on the (bash rather than R) shell via this script derived from an example in the littler package:
and you can easily customize a helper like this for your preferred location. With the script installed in
~/bin/
, I often doand it will faithfully install these packages along with their depends. The littler package has a similar script
update.r
.follow-up on Dirk Eddelbuettel (thanks Dirk!)
an adaptation of Dirk's suggestion that may be run within R:
Usage:
Naturally you want to adapt the repos.loc and lib.dir based on your system. As I work on both Windows and Linux machines I also inserted a conditional statement to check which system I'm on.
P.S. Don't hesitate to simplify the code, I'm a total newbie.