[R] How best to set library search path so user libraries come first
Allan Engelhardt
allane at cybaea.com
Thu Jul 1 18:33:00 CEST 2010
I want my local libraries to have priority over the system installed
ones, which, as far as I can make out from help(".libPaths"), means they
have to come first in that list (it doesn't actually_say_ so, but that
seems to be the idea).
We have R_LIBS_USER which looks made for specifying where I keep my own
libraries. Unfortunately it comes last in .libPaths() [which appears to
me to be a bug (1) if that means last in the search order and (2)
because install.packages() defaults to the first element in .libPaths()
while I think most users would (or rather: should) want to install
packages in R_LIBS_USER most of the time].
My options for getting the order I expect seems to be
(1) Add to ~/.Rprofile a construct along the lines of:
.libPaths(c(Sys.getenv("R_LIBS_USER"), .libPaths()))
(2) Add to ~/.Renviron something like:
R_LIBS=${R_LIBS_USER}:${R_LIBS}
Both of which works but both of which seems very hackish and maybe not
robust :-( Is there a better way? Am I missing how R_LIBS* are
intended to be used?
Allan
More information about the R-help
mailing list