Page MenuHomeSoftware Heritage
Paste P540

List R package versions
ActivePublic

Authored by ardumont on Oct 6 2019, 11:49 AM.
```
$ sudo apt install r-base
```
```
#!/usr/bin/Rscript --vanilla
# This R script:
# - calls the builtin API to install the versions package
# if not already installed.
# - then triggers a version check on the package passed as
# argument to this script.
args = commandArgs(trailingOnly=TRUE)
if (length(args)==0) {
stop("Must supplied one argument (package version to list version from).n", call.=FALSE)
}
# install idempotently an R pkg (no debian package for it yet)
pkgLoad <- function(pkg) {
if (!require(pkg, character.only = TRUE)) {
install.packages(pkg, dep=TRUE)
if(!require(pkg, character.only = TRUE))
stop("Package not found")
}
suppressPackageStartupMessages(library(pkg, character.only = TRUE))
}
pkgLoad('versions')
versions::available.versions(args[1])
```