I recently took the plunge to upgrade R to 2.15. As I was pondering the best way to install all my favorite packages, I stumbled upon this very helpful post from HLPlab
The post describes a very handy way of ensuring that all your favorite packages make it to your new install. Basically this is done via a handy set of code, and involves: 1) saving the names of your packages to a location, and then 2) calling R to then install those packages by name into your new version.
The code with descriptions can be found below:
1. Run the script “store_packages.R” in your current version of R.
# store_packages.R # # stores a list of your currently installed packages tmp = installed.packages() installedpackages = as.vector(tmp[is.na(tmp[,"Priority"]), "Package"]) save(installedpackages, file="packagenames.rda")
Make sure that all the quotation marks in the script are straight. The scripts will generate an error if they include any curly quotation marks. For some reason, when I saved this blog entry, some quotation marks changed to curly ones. WordPress is probably to blame for this problem, which I have not been able to fix.)
2. Close R. Open the installation of R that you want the packages to be installed in.
3. Run the script “restore_packages.R”.
# restore_packages.R # # installs each package from the stored list of packages load(“~/packagenames.rda”) for (count in 1:length(installedpackages)) install.packages(installedpackages[count])
Note that if you want to install the list of packages in an installation of R on a different computer, you should transfer the .rda file that is created by the store_packages script to that computer, and make sure that the path for the “load” command in the restore_packages script is set to the right location.
However, for me, this all may change with my next upgrade–perhaps, as I chose the option to save my packages to a personal library (when 2.15 gave me the option) and my packages are now stored in a different location:
The downloaded binary packages are in