giovedì 23 ottobre 2008

R Upgrade on Mac Os X 10.5.5 (Leopard)

To reinstall packages from an old version of R to a new one.
In the old version type:
tmp <- installed.packages()
installedpkgs <- as.vector(tmp[is.na(tmp[,"Priority"]), 1])
save(installedpkgs, file="installed_old.rda")

Install the most recent version of R:
Download the most recent version of R from The Comprehensive R Archive Network (CRAN)
# To wipe the old R version
rm -rf /Library/Frameworks/R.framework /Applications/R.app
rm -rf /Library/Receipts/R-*

Build from source new R version (see this FAQ).
From inside the decompressed R-?.?.? directory type:
# See Section 2.2 of RMacOSX FAQ for the flag description
./configure --with-blas='-framework vecLib' --enable-BLAS-shlib
make
sudo make install

Install BioConductor packages using the biocLite.R installation script.
In an R command window, type the following:
source("http://bioconductor.org/biocLite.R")
chooseBioCmirror()
biocLite()

If you have other Bioconductor packages missing from the old installation:

load("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])

Re-install the missing packages from CRAN:
load("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()

If you use some package created by Henrik Bengtsson:
source("http://www.braju.com/R/hbLite.R")
hbLite()

If you find your X11 broken after the installation procedure (it happens every time to me, at least on Leopard) install the XQuartz App from here.

Update: If you need to install a recent version of R on old hardware (Power PC G4) and OS (Mac OS X 10.4 here) this post can be useful.