Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting R_LIBS & avoiding "Would you like to use a personal library instead?"

Tags:

r

My personal library is set as R_LIBS=~/.R/lib in ~/.Renviron. This works perfectly well when I install packages from rstudio. When I try installing new packages from a plain R console session, it always asks me:

Would you like to use a personal library instead?  (y/n) y
Would you like to create a personal library
~/R/x86_64-redhat-linux-gnu-library/3.1
to install packages into?  (y/n) n

When I do updates from the console session, existing packages in ~/.R/lib (previously installed from rstudio) are updated no problem. If there are global packages in /usr that also need updating, R again asks if I want to create ~/R/x86_64-redhat-linux-gnu-library/3.1.

I've tried a number of configurations and have not found a way around this.

Pro-tips?

like image 518
drumboots Avatar asked Sep 29 '22 02:09

drumboots


1 Answers

Yes, I always unset it on the systems I use, and I even try to keep it out of the Debian package I maintain. In Debian we use

/usr/lib/R/library                   for core R packages shipping with R
/usr/lib/R/site-library              for r-cran-* packages from the distro
/usr/local/lib/R/site-library        for what the user installs from CRAN

with the appropriate ordering:

R> .libPaths()
[1] "/usr/local/lib/R/site-library" "/usr/lib/R/site-library"   \
    "/usr/lib/R/library"           
R> 

and I do that by commenting this out

#R_LIBS_USER=${R_LIBS_USER-'~/R/x86_64-pc-linux-gnu-library/3.1'}
#R_LIBS_USER=${R_LIBS_USER-'~/Library/R/3.1/library'}

# edd Apr 2003  Allow local install in /usr/local, also add a directory for
#               Debian packaged CRAN packages, and finally the default dir 
# edd Jul 2007  Now use R_LIBS_SITE, not R_LIBS
R_LIBS_SITE=${R_LIBS_SITE-'/usr/local/lib/R/site-library:\
                           /usr/lib/R/site-library:/usr/lib/R/library'}

and I think I have to update my patch in the Debian packaging...

like image 108
Dirk Eddelbuettel Avatar answered Oct 06 '22 03:10

Dirk Eddelbuettel