How’s that done?
<- data.frame(InstPack = installed.packages()[,1]) I1
October 23, 2023
I find updating R to be unnecessarily time-consuming. Much of this is my fault; I do not make good choices about packages and their management. Nevertheless, in my never ending pursuit of engineering solutions to my bad choices, I decided to document a fairly easy workflow for updating and getting a nearly identical updated system. Here are the steps.
I will define an R object I1
[a data.frame with a single character variable InstPack
]
From here, I need to save this in an accessible location.
save(I1, file="InstalledPackagesNov2023.RData")
Go to CRAN and follow the relevant choices to the required option. Download the file and install it.
Click on it. Or open RStudio.
load("InstalledPackagesNov2023.RData")
the purrr::walk
function is very handy.
install.packages("purrr")
purrr::walk(I1$InstPack, ~install.packages(.x))
This will take a while as R attempts to go through and, one by one, install them.
Once this is complete, I need two more things.
In this case, let me create the set of installed packages on this new installation in I2
.
I2 <- data.frame(InstPack = installed.packages()[,1])
dplyr
has an anti-join function that is one of a few ways to find the packages that did not install.
remainder <- dplyr::anti_join(I1, I2)
remainder
Now I know what to go searching for on github because that is where the missing packages come from.
Now I can get smart about this part also. In the process of searching for these, it became useful to go ahead and create an amendable collection of locations for these. For example, d3scatter
.
remainder["d3scatter","loc"] <- "jcheng5/d3scatter"
This is painstaking; past me was unkind to present me in not doing this before. But as long as I save it, or the code in this blog post, then I can recover it all.
After filling in the loc
column in remainder
, I can walk
it with walk(remainder$loc, ~devtools::install_github(.x))
.
remainder["dsbox","loc"] <- "tidyverse/dsbox"
remainder["distilltools","loc"] <- "EllaKaye/distilltools"
remainder["emo","loc"] <- "hadley/emo"
remainder["emoGG","loc"] <- "dill/emoGG"
remainder["equatiomatic","loc"] <- "datalorax/equatiomatic"
remainder["flexpivot","loc"] <- "dreamRs/flexpivot"
remainder["frailtypack","loc"] <- "socale/frailtypack"
remainder["ggflags","loc"] <- "jimjam-slam/ggflags"
remainder["gradethis","loc"] <- "rstudio/gradethis"
remainder["LogisticDx","loc"] <- "dardisco/LogisticDx"
remainder["maptools","loc"] <- ""
remainder["ResampleProps","loc"] <- "robertwwalker/ResampleProps"
remainder["rgeos","loc"] <- ""
remainder["rgdal","loc"] <- ""
remainder["sankeytreeR","loc"] <- "timelyportfolio/sankeytree"