Last active
April 8, 2019 17:23
-
-
Save carlganz/46e35446d3d78336585bf48c6bbfe6a3 to your computer and use it in GitHub Desktop.
If you are upgrading from R 3.2 to R 3.3 you have to go to the hassle of redownloading all your packages. This code will try to download all your old packages.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# get library path | |
lib <- .libPaths()[1] | |
# does it end in 3.3? | |
if (grepl("*3.3",lib)) { | |
# if yes then assume old library is same place with 3.2 instead | |
oldlib <- gsub("*3.3","3.2",lib) | |
} | |
# check that old library exists | |
if (dir.exists(oldlib)) { | |
# if yes then copy names of all old packages | |
pkgs <- list.files(oldlib) | |
} | |
# try installing all old packages | |
install.packages(pkgs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment