确定CRAN上R包的历史记录中的版本数 [英] Determine number of versions in history of R package on CRAN
本文介绍了确定CRAN上R包的历史记录中的版本数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以确定CRAN上的软件包过去的版本数量?
Is it possible to determine the number of versions a package on CRAN has had in the past?
推荐答案
这里是使用 XML 包的一种.这仅计算存档的版本(更准确地说,是存档的tar.gz
文件的数量).加1可获得版本总数,包括当前版本.
Here's one using the XML package. This just counts the archived versions (more precisely, the number of archived tar.gz
files). Add 1 to get the total number of versions, including the current.
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
这篇关于确定CRAN上R包的历史记录中的版本数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文