Update R Packages

The versions of Saagie packages in R jobs and RStudio apps are fixed at a specific date, as well as the CRAN mirror used by default when installing new packages. This ensures consistency between the two technologies and a compatibility between all packages.

To update packages to their latest CRAN version, run the following lines of code:

pkgs <- c("data.table", "dplyr")
for (pkg in pkgs) install.packages(pkg, repos = "https://cloud.r-project.org")

If you need a package in a specific version, there are different methods, such as the renv package. Here is a lightweight alternative to use on Saagie:

options(repos = "https://cloud.r-project.org")
if (!length(find.package("remotes", quiet = TRUE))) install.packages("remotes")
versions <- c(data.table = "1.10.0", dplyr = "0.5.0")
for (pkg in names(versions))
 if (!length(find.package(pkg, quiet = TRUE)) || packageVersion(pkg) != versions[pkg])
 remotes::install_version(pkg, versions[pkg])