Recently I had to upgrade my R installation because I needed to install a library that required a higher version of R than what I had installed. I used to live life on the edge and upgrade R as soon as a new version was available, but as my third-party libs started to grow I started to upgrade R less and less.
A big headache when upgrading R in OS X is that I would loose all the libraries after the upgrade. I would install them as I needed them but that would sometimes end up taking way more time than what I had at that particular time.
I figured I wasn't the only one running into this, so I did some searching around and found this great post on how to upgrade R without loosing all your packages/libraries. The gimmick is to back them up before the upgrade, and then reload them... the catch is that you are not really backing up the packages, but rather, backing up the names of the packages. What the reloading script does is loop through the saved package names and re-install them. Not exactly what I was after, but close enough.
I also modified the Eberwein script so that it would backup the packages to a DropBox location so that I could sync them:
# Backup tmp <- installed.packages() installedpkgs <- as.vector(tmp[is.na(tmp[,"Priority"]), 1]) save(installedpkgs, file="~/Dropbox/R_Packages/installed_old.rda") # CRAN load("~/Dropbox/R_Packages/installed_old.rda") tmp <- installed.packages() installedpkgs.new <- as.vector(tmp[is.na(tmp[,"Priority"]), 1]) missing <- setdiff(installedpkgs, installedpkgs.new) install.packages(missing) update.packages() # BioConductor chooseBioCmirror() # Install if missing source("https://bioconductor.org/biocLite.R”) biocLite() # Reload previously installed load("~/Dropbox/R_Packages/installed_old.rda") tmp <- installed.packages() installedpkgs.new <- as.vector(tmp[is.na(tmp[,"Priority"]), 1]) missing <- setdiff(installedpkgs, installedpkgs.new) for (i in 1:length(missing)) biocLite(missing[i])
One wrinkle to all of this is that some packages will not be compatible with the R version that you are upgrading to; so do check package compatibility before running the upgrade... I ended up with two packages that were not compatible. :(