我刚刚创建了一个包 ( RTIO
) 和一个包存储库 ( Q:/Integrated Planning/R
),这是一个公司网络驱动器。
我已将包裹放入文件夹:
Q:/Integrated Planning/R/bin/windows/contrib/2.15/RTIO_0.1-2.zip
根据 Dirk 在此SO 中的说明,我运行了以下命令:
> setwd("Q:/Integrated Planning/R/bin/windows/contrib/2.15")
> tools::write_PACKAGES(".", type="win.binary")
> list.files()
[1] "PACKAGES" "PACKAGES.gz" "RTIO_0.1-2.zip"
>
使用下面的代码,我已将本地存储库添加到我的存储库列表中(我会让其他用户也这样做):
options(repos = c(getOption("repos"), RioTintoIronOre = "Q:/Integrated Planning/R"))
现在尝试安装我的包我得到一个错误:
> install.packages("RTIO")
Installing package(s) into ‘C:/Program Files/R/R-2.15.1/library’
(as ‘lib’ is unspecified)
Warning in install.packages :
unable to access index for repository Q:/Integrated Planning/R/bin/windows/contrib/2.15
Warning in install.packages :
unable to access index for repository Q:/Integrated Planning/R/bin/windows/contrib/2.15
Warning in install.packages :
unable to access index for repository Q:/Integrated Planning/R/bin/windows/contrib/2.15
Warning in install.packages :
package ‘RTIO’ is not available (for R version 2.15.1)
unable to access index for repository
告诉我什么?我该如何解决?
我真正想做的是,在 Windows 下并使用 RStudio 作为 IDE,让其他内部 R 用户添加这个包 repo,以便他们能够运行类似的命令install.packages("RTIO")
或update.packages()
获取包的新版本(并且可能还有能够使用 IDE 通过 GUI 管理包)。
更新:
感谢agstudy的回答,我更近了一步。这是我得到的输出。
> getOption("repos")
CRAN CRANextra
"http://cran.ms.unimelb.edu.au/" "http://www.stats.ox.ac.uk/pub/RWin"
> setRepositories(addURLs=c(RioTintoIronOre = "file://Q:/Integrated Planning/R"))
--- Please select repositories for use in this session ---
1: + CRAN
2: + CRAN (extras)
3: BioC software
4: BioC annotation
5: BioC experiment
6: BioC extra
7: Omegahat
8: R-Forge
9: rforge.net
Enter one or more numbers separated by spaces, or an empty line to cancel
1:
> getOption("repos")
RioTintoIronOre
"file://Q:/Integrated Planning/R"
> install.packages("RTIO")
Installing package(s) into ‘C:/Program Files/R/R-2.15.1/library’
(as ‘lib’ is unspecified)
Warning in install.packages :
cannot open compressed file '//Q:/Integrated Planning/R/bin/windows/contrib/2.15/PACKAGES', probable reason 'No such file or directory'
Error in install.packages : cannot open the connection
跟进问题:
为什么在使用时提示我选择存储库
setRepositories()
?当我在不输入数字的情况下点击“输入”并检查
getOption("repos")
它只显示File://Q:/Integrated Planning/R
存储库。这是为什么?当我这样做
install.packges("RTIO")
时,它似乎找到了文件,但给出了警告cannot open compressed file
和错误cannot open the connection
。注意list.files()
上面的输出。知道为什么吗?