```
$ sudo apt install r-base
```
```
#!/usr/bin/Rscript --vanilla
# This R script calls the buildin API to get list of
# all the packages of R and their description, then convert the API
# response to JSON string and print it
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])
```