Moving or copying the library when upgrading R

Because I need to be sure that my packages work with current versions of R, I nowadays cannot skip any R update. I use many different packages, so re-installing all the packages in the library is something I would rather avoid.
Today I found that an easy way to automate this task is to use package installr, more specifically, a function with a very long, but descriptive name copy.packages.between.libraries().

library(installr)
copy.packages.between.libraries(ask = TRUE, keep.old = TRUE)

Will ask you to choose source and destination libraries from a list of available ones and copy without deleting them from the old library all packages. Using keep.old = FALSE, the default, will move the packages, and ask = FALSE the default will automatically select source and destination. This automatic guessing did not select the direction I expected for the case of a patched versus released version of R.
Anyway this is handy when one has, as the function itself reported some minutes ago 144 packages to move!
If you do not use patched versions of R this should be enough.

library(installr)
copy.packages.between.libraries()

I hope this bit of advice will make less painful my decision of no-longer supporting R 3.1.X and earlier!

Leave a Reply

Your email address will not be published. Required fields are marked *