Help regarding package installation: .Renviron, .Rprofile, R_LIBS, R_LIBS_SITE, and R_LIBS_USER Oh my!

From what I've gathered (which may be totally wrong):

  • R_LIBS_USER
    • Intended to list libraries for a user, which doesn't affect other users.
    • Environment variable which is read at start-up.
    • This would work for you.
  • R_LIBS_SITE
    • Intended to list libraries shared by multiple users at a site (e.g., the same computer).
    • Environment variable which is read at start-up.
    • Good if there's an admin who takes care of installs and upgrades, but not for your situation.
  • .libPaths()
    • Shows libraries in the search path or adds them.
    • Executed in an R session.
    • This would also work for you.
  • R_LIBS:
    • Environment variable which is read at start-up.
    • I have no idea of the intent behind this one.

If you'd like to use R_LIBS_USER, add an .Renviron file to your home directory that has this line:

R_LIBS_USER=c:/users/USER/software/r/libraries/3.5

If you'd like to use .libPaths() instead, add an .Rprofile file to your home directory that has this line:

.libPaths("c:/users/USER/software/r/libraries/3.5")

Either of those should work for as long as the relevant file is in your home directory.

6 Likes