Created
April 24, 2020 14:49
-
-
Save cdesante/6df438608190b5b4b50797a23e5ae8c8 to your computer and use it in GitHub Desktop.
Reinstalling All Packages for R 4.0
This file contains hidden or 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
#In R 3.6, run: | |
.libPaths()[1] | |
#Copy this directory path and paste it on the line below; | |
#Then run all lines below in R 4.0: | |
PASTED <- "C:/Users/.../R/win-library/3.6" | |
currentPackages <- list.dirs(path = PASTED , recursive = FALSE) | |
currentPackages | |
trimmed <- stringr::str_replace_all(currentPackages, paste(PASTED , "/", sep = ""), "") | |
toInstall <- dput(trimmed) | |
doInstall <- TRUE | |
if(doInstall){install.packages(toInstall, repos = "http://cran.r-project.org", dependencies = TRUE)} | |
lapply(toInstall, library, character.only = TRUE) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment