Saturday, June 29, 2013

Updating R – in Windows 7

R is a great statistical software with tremendous flexibility. However, there is not a very straightforward (point and clinic) way of updating it. R Users have developed several different methods of updating R with its packages, including one described on CRAN.

I came across this one post, it is about updating R on Mac; tried it on Windows 7 with minor changes and it worked fine.

So here is what I did:
First, in the older version I wrote following commands
tmp <- installed.packages()
installedpkgs <- as.vector(tmp[is.na(tmp[,"Priority"]), 1])
save(installedpkgs, file="installed_old.rda")

Then I downloaded and installed newer version of the R. In the newer version of R I wrote following commands:
source(
http://bioconductor.org/biocLite.R)
biocLite()
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])

All packages were automatically installed to the newer version. Then, I went to Windows Control Panel and uninstalled the older version of R.

That’s it!

No comments: