Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Logic of installation location of R packages under Linux

Tags:

linux

r

What's the logic behind the different installation locations of various R packages? I seem to have packages installed in several different locations on my linux machine. Is this typical behavior and if so what is the rational for installing a package in /usr/lib/R/library vs /usr/lib/R/site-library? I don't really care where the package is installed but it does seem kind of silly to have the installations spread out in different locations across my system.

Renviron has the comment below, which seems to suggest that /usr/lib/R/site-library is for Debian packaged packages, but doesn't really explain the purpose of the other two directories. Also, by setting /usr/lib/R/library last in the list doesn't that make it not the default dir for install.packages()?

# edd Apr 2003  Allow local install in /usr/local, also add a directory for
#               Debian packaged CRAN packages, and finally the default dir 


> .libPaths()
[1] "/usr/local/lib/R/site-library" "/usr/lib/R/site-library"      
[3] "/usr/lib/R/library"     
like image 221
matt_k Avatar asked Sep 24 '11 18:09

matt_k


1 Answers

Matt,

You generalize the wrong way from the specific (Debian/Ubuntu) to the generic (all Linux distros).

This particular setup was suggested to me by two Debian-using R Core members (and this was before the dawn of Ubuntu). This is not an R-wide recommendation which is why you will not find it in the manuals, but rather a specific recommendation by R power users to be implemented on Debian and Debian-alike systems.

The basic idea is

  • to remain totally faithful to the separation of /usr/, /var/, .... to be handled by the package management system (eg apt-get, dpkg, ...) on the one hand, and /usr/local/... etc by the user on the other hand: these two shall never mix

  • so that /usr/local/lib/R/site-library gets the first spot in the list emitted by .libPaths() and thus becomes the default, thus ensuring that user-installed package end up below /usr/local/ as per the previous point

  • so that below /usr we get a separation between R's recommended packaged (included in the basic R sources too: boot, grid, lattice, ...) inside /usr/lib/R/library, and then all other package management controlled r-cran-* packages below /usr/lib/R/site-library. So e.g. r-cran-xml ends up there, or r-cran-zoo, or ...

I still think the split is terrific, and that is why I maintain this setup in the Debian R packages.

Having the local packages site-wide for all users is a good idea on a multi-user operating system.

like image 105
Dirk Eddelbuettel Avatar answered Sep 20 '22 15:09

Dirk Eddelbuettel