Save your R packages when updating R version

April 24, 2018 · 1 minute read

This post is a copy and paste of an r-blogger article.

However, it is so useful that I keep it here to remember about the process to save and restore all R packages when updating to a newer version of R.

  • Before you upgrade, build a temp file with all of your old packages.
tmp <- installed.packages()
installedpkgs <- as.vector(tmp[[,"Priority"]), 1])
save(installedpkgs, file="installed_old.rda")
  • Install the new version of R and let it do it’s thing.

  • Once you’ve got the new version up and running, reload the saved packages and re-install them from CRAN.

tmp <- installed.packages() <- as.vector(tmp[[,"Priority"]), 1])
missing <- setdiff(installedpkgs,