Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R: Updating .libPaths() on Ubuntu

Tags:

r

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?

like image 717
tchakravarty Avatar asked Sep 18 '25 10:09

tchakravarty


1 Answers

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/".

like image 126
Dirk Eddelbuettel Avatar answered Sep 21 '25 02:09

Dirk Eddelbuettel