Skip to content

Instantly share code, notes, and snippets.

@cdesante
Created April 24, 2020 14:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cdesante/6df438608190b5b4b50797a23e5ae8c8 to your computer and use it in GitHub Desktop.
Save cdesante/6df438608190b5b4b50797a23e5ae8c8 to your computer and use it in GitHub Desktop.
Reinstalling All Packages for R 4.0
#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