我正在查看install.packages
,我没有看到任何指定特定版本的选项。有办法吗?我希望找到像install.packages(c('xts'),version='0.9.3')
我找到了这个答案:https://stackoverflow.com/a/12679452/841830 但是,在安装devtools后,我做了:
library(devtools)
install_version('xts','0.9.3')
它给出了此错误消息:
Error in url(sprintf("%s/src/contrib/Archive.rds", repos), "rb") :
cannot open the connection
In addition: Warning message:
In url(sprintf("%s/src/contrib/Archive.rds", repos), "rb") :
cannot open: HTTP status was '404 Not Found'
3: url(sprintf("%s/src/contrib/Archive.rds", repos), "rb")
2: gzcon(url(sprintf("%s/src/contrib/Archive.rds", repos), "rb"))
1: install_version("xts", "0.9.3")
(使用“0.9-3”,连字符代替点,给出相同的错误。)
背景:我在xts rollapply函数调用中有一个回归,因为从0.9.3升级到0.9.4。然而,当我查看在线svn存储库时,似乎没有任何变化,因为我知道它最后工作。所以我想安装0.9.3(然后是0.9.2等)来确切确定问题的确定时间。
答案 0 :(得分:4)
现在,函数install_version
似乎与当前的CRAN存档存在一些问题,您已经确定了前两个:
0.9-3
中的连字符被点替换。src/contrib/Archive.rds
(它在CRAN上移至src/contrib/Meta/archive.rds
。)我发送了一个针对这些问题的修复请求,因此应该尽快修复devtools。如果您想在此期间使用install_version
,请加载库devtools
,但请使用此稍加编辑的功能:
install_version <- function(package, version = NULL, repos = getOption("repos"), type = getOption("pkgType"), ...) {
contriburl <- contrib.url(repos, type)
available <- available.packages(contriburl)
if (package %in% row.names(available)) {
current.version <- available[package, 'Version']
if (is.null(version) || version == current.version) {
return(install.packages(package, repos = repos, contriburl = contriburl,
type = type, ...))
}
}
con <- gzcon(url(sprintf("%s/src/contrib/Meta/archive.rds", repos), "rb"))
on.exit(close(con))
archive <- readRDS(con)
info <- archive[[package]]
if (is.null(info)) {
stop(sprintf("couldn't find package '%s'", package))
}
if (is.null(version)) {
# Grab the latest one: only happens if pulled from CRAN
package.path <- info[length(info)]
} else {
package.path <- paste(package, "/", package, "_", version, ".tar.gz",
sep = "")
if (!(package.path %in% row.names(info))) {
stop(sprintf("version '%s' is invalid for package '%s'", version,
package))
}
}
url <- paste(repos, "/src/contrib/Archive/", package.path, sep = "")
install_url(url, ...)
}
答案 1 :(得分:1)
如果所有其他方法都失败了,您可以直接从CRAN获取来源:http://cran.r-project.org/src/contrib/Archive/xts/xts_0.9-3.tar.gz