Skip to content

Instantly share code, notes, and snippets.

@TheZetner
Last active December 30, 2019 20:06
Show Gist options
  • Save TheZetner/b4a76171959797e06807d0d865fbf0a3 to your computer and use it in GitHub Desktop.
Save TheZetner/b4a76171959797e06807d0d865fbf0a3 to your computer and use it in GitHub Desktop.
Update R Packages on Windows After Updating R
# 1. Before you upgrade, build a temp file with all of your old packages.
tmp <- installed.packages()
installedpkgs <- as.vector(tmp[is.na(tmp[,"Priority"]), 1])
save(installedpkgs, file="installed_old.rda")
# 2. Install the new version of R and let it do its thing.
# 3. Once you’ve got the new version up and running, reload the saved packages and re-install them from CRAN.
load("installed_old.rda")
tmp <- installed.packages()
installedpkgs.new <- as.vector(tmp[is.na(tmp[,"Priority"]), 1])
missing <- setdiff(installedpkgs, installedpkgs.new)
install.packages(missing)
update.packages()
@TheZetner
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment