Determine the number of versions in the history of the R-package on CRAN

Is it possible to determine the number of versions that a package had on CRAN in the past?

+5
source share
2 answers

It uses an XML package. This is simply an account of archived versions (more precisely, the number of archived tar.gz files). Add 1 to get the total number of versions, including the current one.

 nCRANArchived <- function(pkg) { link <- paste0("http://cran.r-project.org/src/contrib/Archive/", pkg) qry <- XML::getHTMLLinks(link, xpQuery = "//@href[contains(., 'tar.gz')]") length(qry) } nCRANArchived("data.table") # [1] 33 nCRANArchived("ggplot2") # [1] 28 nCRANArchived("MASS") # [1] 40 nCRANArchived("retrosheet") ## shameless plug # [1] 2 
+7
source

Here is a simple function that goes to the CRAN page with old versions of this package and counts them.

 num.versions = function(package) { require(rvest) require(stringr) # Get text of web page with package version info page = read_html(paste0("https://cran.r-project.org/src/contrib/Archive/", package, "/")) doc = html_text(page) # Return number of versions (add 1 for current version) paste("Number of versions: ", length(unlist(str_extract_all(doc, "tar\\.gz"))) + 1) } num.versions("ggplot2") [1] "Number of versions: 29" num.versions("data.table") [1] "Number of versions: 34" num.versions("distcomp") [1] "Number of versions: 4" 
+4
source

All Articles