Last active
October 5, 2023 12:08
-
-
Save andrewmoles2/18e1a636aeadc42f503212fde1ddc6ba to your computer and use it in GitHub Desktop.
Revisions
-
andrewmoles2 revised this gist
Jun 8, 2022 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -8,7 +8,10 @@ my_pkg <- pak::pkg_list() # if loaded from finder saveRDS(object = my_pkg, file = "my_packages.rds") # -------------- # now upgrade R - https://www.r-project.org/ # -------------- # after upgrade, bring back the rds file my_pkg <- readRDS("my_packages.rds") -
andrewmoles2 created this gist
Jun 8, 2022 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,36 @@ # script to upgrade R and re-install all (or at least most) packages # Pre-upgrade: save your packages as an rds file my_pkg <- pak::pkg_list() # if loaded from RStudio #here::here("R", "update_packages", "my_packages.rds") # if loaded from finder saveRDS(object = my_pkg, file = "my_packages.rds") # upgrade R # after upgrade, bring back the rds file my_pkg <- readRDS("my_packages.rds") # first, install all the cran packages inst <- my_pkg$package[my_pkg$repository == "CRAN"] install.packages(inst, type = "binary", Ncpus = 6) # check what is installed now <- pak::pkg_list() # see what is missing missing <- my_pkg[!my_pkg$package %in% now$package, ] # if installed from github, make name vector add <- paste0(missing$remoteusername, "/", missing$remoterepo) add <- add[!add %in% "NA/NA"] # now install github pak::pak(add) # see if there is anything left final <- pak::pkg_list() final_missing <- my_pkg[!my_pkg$package %in% final$package, ] paste(final_missing$package)