install.packages错误:解决本地repo使用问题

时间:2012-12-11 05:00:59

标签: r

我刚创建了一个包(RTIO)和一个包存储库(Q:/Integrated Planning/R),这是一个公司网络驱动器。

我已将我的包裹放入文件夹:

Q:/Integrated Planning/R/bin/windows/contrib/2.15/RTIO_0.1-2.zip

根据Dirk在this 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"
>

使用下面的代码,我已将本地存储库添加到我的repos列表中(我将让其他用户也这样做):

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")或{{1}等命令获取软件包的新版本(并且可能也可以使用IDE通过GUI管理软件包)。


UPDATE:

由于agstudy的答案,我向前迈进了一步。这是我得到的输出。

update.packages()

跟进问题:

  1. 为什么在我使用> 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 时会提示我选择存储库?

  2. 当我在没有输入数字的情况下点击“输入”,并检查setRepositories()它只显示getOption("repos")存储库。那是为什么?

  3. 当我File://Q:/Integrated Planning/R时,它似乎找到了该文件,但发出了警告install.packges("RTIO")和错误cannot open compressed file。请注意上面cannot open the connection的输出。知道为什么吗?

2 个答案:

答案 0 :(得分:4)

为了避免这个消息:

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'



//

中指定网址时,请尝试此操作以删除setRepositories
> setwd("Q:/Integrated Planning/R/bin/windows/contrib/2.15")
> tools::write_PACKAGES(".", type="win.binary")
> setRepositories(addURLs=c(RioTintoIronOre = "file:Q:/Integrated Planning/R"))
> install.packages("RTIO")

答案 1 :(得分:2)

你有警告unable to access index for repository 因为install.packages尝试在远程存储库(无本地)中访问您的自定义包。

要解决此问题,您需要将本地存储库添加到R-options repos。 您需要将其添加为URL路径而不是文件路径。类似于file://

做这样的事情:

      setRepositories(addURLs=c(lRioTintoIronOre = "file://Q:/Integrated Planning/R"))

要检查一切是否正确,以下内容必须返回TRUE:

    repos <- contrib.url(getOption('repos'))
    length(grep("^file:", repos)) > 0L