是否有一种简便的方法来获取包含特定日期的CRAN软件包及其版本的列表?
例如像这样的代码:
package_versions(packages = c("data.table", "lubridate"), date = "2018-01-01")
# Output
tribble(~package, ~version,
"data.table", "1.10.4-3",
"lubridate", "1.7.1")
一个想法是将检查点设置为特定日期,然后使用类似packageVersion
的名称。但是我想知道是否有一些更简单的方法不需要安装所有这些软件包。也许抓https://mran.microsoft.com/timemachine?
答案 0 :(得分:2)
尝试一下:
pack_version <- function(pack_list,date){
require(rvest)
myfunc <- function(x=pack_list,){
url<-paste0("https://cran.microsoft.com/snapshot/", date,"/web/packages/", x, "/index.html")
webpage <- read_html(url)
table <- html_nodes(webpage, xpath='//td')
html_text(table)[2]
}
sapply(pack_list, myfunc, date=date)
}
pack_list <- c("ggplot2", "abind")
date <- "2016-08-01"
pack_version(pack_list, date)
ggplot2 abind
"2.1.0" "1.4-5"
答案 1 :(得分:0)
不是一个真正的答案,但这可能会有所帮助。
library(versions)
#---- try:
x <- available.versions(c("lubridate", "data.table"))
#---- if you get an error with the above line, do:
# save the current locale
lct <- Sys.getlocale("LC_TIME")
# set the C locale
Sys.setlocale("LC_TIME", "C")
# now this should work
x <- available.versions(c("lubridate", "data.table"))
# restore the locale
Sys.setlocale("LC_TIME", lct)
> x
$lubridate
version date available
1 1.7.4 2018-04-11 TRUE
2 1.7.3 2018-02-27 TRUE
3 1.7.2 2018-02-06 TRUE
4 1.7.1 2017-11-03 TRUE
5 1.6.0 2017-11-02 TRUE
6 1.7.0 2017-10-29 TRUE
7 1.5.6 2016-04-05 TRUE
8 1.5.0 2015-12-02 TRUE
9 1.3.3 2013-12-31 TRUE
10 1.3.2 2013-12-05 FALSE
11 1.3.1 2013-10-31 FALSE
12 1.3.0 2013-09-20 FALSE
13 1.2.0 2012-10-04 FALSE
14 1.1.0 2012-03-05 FALSE
15 0.2.6 2012-01-10 FALSE
16 0.2.5 2011-05-12 FALSE
17 0.2.4 2011-04-05 FALSE
18 0.2.3 2010-12-09 FALSE
19 0.2.2 2010-11-17 FALSE
20 0.2.1 2010-11-03 FALSE
21 0.2 2010-10-26 FALSE
22 0.1 2010-08-15 FALSE
$data.table
version date available
1 1.11.4 2018-05-27 TRUE
2 1.11.2 2018-05-08 TRUE
3 1.11.0 2018-05-01 TRUE
4 1.10.4-3 2017-10-27 TRUE
5 1.10.4-2 2017-10-12 TRUE
6 1.10.4-1 2017-10-09 TRUE
7 1.10.4 2017-02-01 TRUE
8 1.10.2 2017-01-31 TRUE
9 1.10.0 2016-12-03 TRUE
10 1.9.8 2016-11-25 TRUE
11 1.9.6 2015-09-19 TRUE
12 1.9.4 2014-10-02 TRUE
13 1.9.2 2014-02-27 TRUE
14 1.8.10 2013-09-03 FALSE
15 1.8.8 2013-03-06 FALSE
16 1.8.6 2012-11-13 FALSE
17 1.8.4 2012-11-09 FALSE
18 1.8.2 2012-07-17 FALSE
19 1.8.0 2012-07-16 FALSE
20 1.7.10 2012-02-07 FALSE
21 1.7.9 2012-01-31 FALSE
22 1.7.8 2012-01-25 FALSE
23 1.7.7 2011-12-15 FALSE
24 1.7.6 2011-12-13 FALSE
25 1.7.5 2011-12-04 FALSE
26 1.7.4 2011-11-29 FALSE
27 1.7.3 2011-11-25 FALSE
28 1.7.2 2011-11-07 FALSE
29 1.7.1 2011-10-22 FALSE
30 1.6.5 2011-08-25 FALSE
31 1.6.6 2011-08-25 FALSE
32 1.6.4 2011-08-10 FALSE
33 1.6.3 2011-08-04 FALSE
34 1.6.2 2011-07-02 FALSE
35 1.6.1 2011-06-29 FALSE
36 1.6 2011-04-24 FALSE
37 1.5.3 2011-02-11 FALSE
38 1.5.2 2011-01-21 FALSE
39 1.5.1 2011-01-08 FALSE
40 1.5 2010-09-14 FALSE
41 1.4.1 2010-05-03 FALSE
42 1.2 2008-09-01 FALSE
43 1.1 2008-08-27 FALSE
44 1.0 2006-04-14 FALSE