Upgrading R (and packages)

I tend not to upgrade R very often—running from 6 months to 1 year behind in version numbers—because I had to reinstall all packages: a real pain. A quick search shows that people have managed to come up with good solutions to this problem, as presented in this stackoverflow thread. I used the code in my mac:

# Run in the old installation (pre-upgrade)
# saving a list of installed packages
setwd('~/Downloads')
package.list = installed.packages()[,"Package"]
save(package.list, file='package-list.Rdata')
 
# Run in new install
setwd('~/Downloads')
load('package-list.Rdata')
for (p in setdiff(package.list, installed.packages()[,"Package"])) {
    install.packages(p)
}
 
# Final output
Warning messages:
1: In getDependencies(pkgs, dependencies, available, lib) :
  package ‘Acinonyx’ is not available (for R version 2.13.2)
2: In getDependencies(pkgs, dependencies, available, lib) :
  package ‘AnimalINLA’ is not available (for R version 2.13.2)
3: In getDependencies(pkgs, dependencies, available, lib) :
  package ‘asreml’ is not available (for R version 2.13.2)
4: In getDependencies(pkgs, dependencies, available, lib) :
  package ‘INLA’ is not available (for R version 2.13.2)
5: In getDependencies(pkgs, dependencies, available, lib) :
  package ‘graph’ is not available (for R version 2.13.2)

From all installed packages, I only had issues with 5 of them, which require installation from their respective websites: Acinonyx, INLA (and AnimalINLA) and asreml. Package graph is now available from bioconductor.org. INLA can be installed really easily from inside R (see below), while I did not bother downloading again asreml and just copied the folder from ~/Library/R/OldVersion/library/asreml to ~/Library/R/CurrentVersion/library/asreml.

# Installing INLA
source("http://www.math.ntnu.no/inla/givemeINLA.R")
inla.upgrade(testing=TRUE)

Overall, it was a good upgrade experience, so thanks to the stackoverflow crowd for so many ideas on how to make R even nicer than it is.

P.S. 20100-10-14 Similar instructions, but including compiling R and installing bioconductor.

Leave a Reply