13

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"     

1 Answer 1

11

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.

1
  • Okay thanks. I figured that there was probably a reason for the splits that I as a relatively new Linux (Ubuntu) user didn't grasp.
    – matt_k
    Sep 24, 2011 at 23:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.