Skip to content

REQ - Add guidance for installing packages on the new workbench using the saved CSV #148

Description

@Moohan

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()

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    new docNew doc or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions