A suggestion is here, probably including just Option 1 is simplest, but I wasn't sure why the versions of packages were saved in the CSV... I used pak as it allows installing package versions as a vector, whereas remotes can only do one at a time.
load_path <- rstudioapi::selectFile(
caption = "Select location to load CSV file",
label = "Load",
existing = TRUE,
filter = "CSV files (*.csv)"
)
package_info <- read.csv(load_path)
# Set installs to use multiple cores (should be faster)
install.packages("parallelly")
available_cores <- as.numeric(parallelly::availableCores())
options(Ncpus = available_cores)
Sys.setenv(MAKEFLAGS = paste("-j", as.character(available_cores), sep = ""))
# Option 1 - Install the latest version of all packages
install.packages(package_info[["Package"]])
# Option 2 - Install matching versions of the packages
# This may not work as some old versions might be incompatible with the latest R version
install.packages("pak")
paste(package_info[["Package"]], package_info[["Version"]], sep = "@") |>
pak::pkg_install()
# This can also be used for PHS packages
paste0(
"Public-Health-Scotland/",
c("phsopendata", "phsstyles", "phstemplates", "phsverse", "slfhelper")
) |>
pak::pkg_install()
A suggestion is here, probably including just Option 1 is simplest, but I wasn't sure why the versions of packages were saved in the CSV... I used
pakas it allows installing package versions as a vector, whereasremotescan only do one at a time.