4

I am trying to follow advice here & here, to update the location where R looks for installed packages. I have updated the variable .Library.site in the /etc/R/Rprofile.site file to include the location of the intended R package library directory:

Sys.setenv(".Library.site" = "~/AppData/R/x86_64-pc-linux-gnu-library/") 

However, when I start up R, and do a .libPaths() the location is not appended to the list of library locations. Why?

Community
  • 1
  • 1
tchakravarty
  • 10,736
  • 12
  • 72
  • 116

1 Answers1

5

Three answers:

  1. Your approach is wrong. .libPath() is an R function, not an environment variable. What you do above above cannot work.

  2. Per a consensus with (some members of) R Core, I have been setting the path to three location since circa 2003 for Debian / Ubuntu. That is done below /etc/R/ and you probably saw it.

  3. The easiest to set a per-user directory would be via R_LIBS_USER which I typically comment-out as I like as users on a machine to have consistent paths. You can set it either in the global Renviron, or in the global Renviron.site (better) or in ~/.Renviron (probably best). You do that via R_LIBS_USER="~/AppData/R/x86_64-pc-linux-gnu-library/".

Dirk Eddelbuettel
  • 360,940
  • 56
  • 644
  • 725
  • Thanks Dirk. Safe to assume that `~/.Renviron` not created by default, and that if one does not exist, can create one? – tchakravarty Jun 04 '15 at 12:08
  • Also, not clear on your 1. & 2. If I do successfully change the location of the package directory, I should be able to retrieve it from within R using `libPaths()`, right? Re. 2. when you say that you set the location in 3 places you mean that this can be achieved using one of the `*.site` files in the `/etc/R` directory, right? Apologies for the confusion, new to manipulating environment variables for R. – tchakravarty Jun 04 '15 at 12:11
  • Huh? I am asking a follow-on question about your consensus with the R core members. Unlikely that is discussed in `help(Startup)`? – tchakravarty Jun 04 '15 at 12:34
  • I am sorry but I already gave you the directory. If that wasn't specific enough, try `cat /etc/R/Renviron` and *what those values mean is described in the help page I just pointed you to*. – Dirk Eddelbuettel Jun 04 '15 at 12:49