user797963 user797963 - 7 days ago 6
R Question

How can I use multiple library paths?

I'm trying to set up an easy to use R development environment for multiple users. R is installed along with a set of other dev tools on an NFS mount.

I want to create a core set of R packages that also live on NFS so n users don't need to install their own copies of the same packages n times. Then, I was hoping users can install one off packages to a local R library. Has anyone worked with an R setup like this before? From the doc, it looks doable by adding both the core package and personal package file paths to

.libPaths()
.

Answer

You want to use the .Renviron file (see ?Startup).

There are three places to put the file:

  • Site wide in R_HOME/etc/Renviron.site
  • Local in either the current working directory or the home area

In this file you can specify R_LIBS and the R_LIBS_SITE environment variables.

For your particular problem, you probably want to add the NFS drive location to R_LIBS_SITE in the R_HOME/etc/Renviron.site file.


## To get R_HOME
Sys.getenv("R_HOME")
Comments