In documents I want to be able to refer to the version of a package installed on CRAN, which may be behind the version I currently have installed.
I can do this using available.packages()
, but this downloads the entire CRAN package list (350K lines, 10Mb), so I wonder if there is something simpler.
#' Find version of a package on CRAN
cran_version <- function(package) {
avail <- utils::available.packages(filters = "CRAN")
avail <- avail[, c("Package", "Version")]
which <- avail[, "Package"] == package
avail[which, "Version"]
}
> packageVersion("heplots")
[1] ‘1.6.3’
> cran_version("heplots")
[1] "1.6.2"