There are basically two strategies for R upgrading on windows. The first is to install a new R version and copy paste all the packages to the new R installation folder. The second is to have a global R package folder, each time synced to the most current R installation (thus saving us the time of copying the package library each we upgrade R).
After Andrew Gelman recently lamented the lack of an easy upgrade process for R, a Stackoverflow thread (by JD Long) invited R users to share their strategies for easily upgrading R.
Upgrading strategy – moving to a global R library
In that thread, Dirk Eddelbuettel suggested another idea for upgrading R. His idea is of using a folder for R’s packages which is outside the standard directory tree of the installation (a different strategy then the one offered on the R FAQ).
The idea of this upgrading strategy is to save us steps in upgrading. So when you wish to upgrade R, instead of doing the following three steps:
download new R and install
copy the “library” content from the old R to the new R
upgrade all of the packages (in the library folder) to the new version of R.
You could instead just have steps 1 and 3, and skip step 2 (thus, saving us time…).
For example, under windows XP, you might have R installed on: C:Program FilesRR-2.11.0
But (in this alternative model for upgrading) you will have your packages library on a “global library folder” (global in the sense of independent of a specific R version): C:Program FilesRlibrary
So in order to use this strategy, you will need to do the following steps (all of them are performed in an R code provided later in the post)-
In the OLD R installation (in the first time you move to the new system of managing the upgrade):
Create a new global library folder (if it doesn’t exist)
Copy to the new “global library folder” all of your packages from the old R installation
After you move to this system – the steps 1 and 2 would not need to be repeated. (hence the advantage)
In the NEW R installation:
Create a new global library folder (if it doesn’t exist – in case this is your first R installation)
Premenantly point to the Global library folder whenever R starts
(Optional) Delete from the “Global library folder” all the packages that already exist in the local library folder of the new R install (no need to have doubles)
Update all packages. (notice that you picked a mirror where the packages are up-to-date, you sometimes need to choose another mirror)
Thanks to help from Dirk, David Winsemius and Uwe Ligges, I was able to write the following R code to perform all the tasks I described