Managing R packages

We still don’t have proper integration of CRAN and BIOC in Gentoo. I have proposed a GSoC project to remedy that. Feel free to contact me about it.

In the meantime if you need to install CRAN or BIOC packages you probably use install.packages() in R. This resolves R dependencies and installs all you need automatically. You are on your own about system dependencies though, but this is what CRAN integration in Portage is about. Upstream recommends you su root when installing R packages from within R. This is not always possible and I hope you will agree with me this is not the right thing to do. At best you will make your package manager cry due to collisions. At worst, well, it can be way worse. The recommended way should be for users to manage their R packages in their personal library. If you don’t have one, a personal library will be created for you the first time you use install.packages() or update.packages(). So there is nothing special to do and it mostly works.

One problem arises when a package you are installing depends on a version of a recommended package newer than the one you have. Recommended packages are some of those which are installed by Portage when you emerge R, thus they are owned by root. Non-root users can’t update them in the main library, which they don’t have access to, but they can do so in their personal library. However, there is a bug in R which will let you update recommended packages in your personal library, but only if you didn’t have one when you started the process. If you had one, as it’s most likely the case, the install will just fail. Frustrating.

About four weeks ago I silently added two patches to dev-lang/R-2.14.2 in order to fix this behavior. So far nobody complained. Yesterday I bumped R to 2.15.0 and the patches still apply cleanly. Please test and report back.

I have filed a bug upstream about these patches. Let’s see what they make out of them. The real solution to this problem though, at least as far as Gentoo is concerned, is to have Portage manage your R packages. And I’m sure it will come someday.