7

I've just created a package (RTIO) and a package repository (Q:/Integrated Planning/R), which is a company network drive.

I've put my package into the folder:

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

As per Dirk's instructions in this SO, I've run the following commands:

> 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"
>

With the code below, I've added the local repository to my list of repos (and I'll get other users to do the same):

options(repos = c(getOption("repos"), RioTintoIronOre = "Q:/Integrated Planning/R"))

And now trying to install my package I get an error:

> 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)

What does unable to access index for repository tell me? And how can I fix it?

What I'm really looking to do is, under Windows and with RStudio as the IDE, let other internal R users add this package repo such that they're able to run commands like install.packages("RTIO") or update.packages() to get new versions of the package (and presumably also be able to use the IDE to manage packages via the GUI).


UPDATE:

I'm one step closer thanks to agstudy's answer. Here's the output that I get.

> 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

Follow Up Questions:

  1. Why does it prompt me to select a repository when I use setRepositories()?

  2. When I hit 'enter' without typing in a number, and check getOption("repos") it only shows the File://Q:/Integrated Planning/R repository. Why is that?

  3. When I do install.packges("RTIO") it seems to find the file, but gives a warning cannot open compressed file and an error cannot open the connection. Note the output from list.files() above. Any idea why?

Community
  • 1
  • 1
Tommy O'Dell
  • 7,019
  • 13
  • 56
  • 69
  • Sorry Tyler, I don't understand how that question is relevant. That one is about the process of building a package, this question is about installing from a local repository. Note that I need this to work via `install.packages` - I don't expect users of this package to be using anything like `devtools`. – Tommy O'Dell Dec 11 '12 at 06:05
  • 1
    Gotcha I misunderstood the problem. I removed the comment. – Tyler Rinker Dec 11 '12 at 07:08
  • I'm pretty sure you're supposed to end up with `PACKAGES` in `Q:/Integrated Planning/R`, not the windows specific directory. – hadley Dec 11 '12 at 11:52

2 Answers2

4

In order to avoid this message:

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'



Try this to remove // when specifying url in 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")
2

You have the warning unable to access index for repository because install.packages try to access your custom package in a distant repository ( no local).

To fix this you need to add your local repository to your R-options repos. You need to add it as url path and not file path. something like file://

Do something like this:

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

To check if all is correct , the following must return TRUE :

    repos <- contrib.url(getOption('repos'))
    length(grep("^file:", repos)) > 0L 
agstudy
  • 119,832
  • 17
  • 199
  • 261
  • Hey mate, thanks so much for your answer. This seem to have brought me closer but am now experiencing some other issues. I've updated my question with details. – Tommy O'Dell Dec 11 '12 at 08:15
  • `setRepositories` doesn't stick between sessions, so I've changed my `Rprofile.site` to permanently add the local repo. (Found instructions on how to do this in the file itself). Now when I type `getOption("repos")` in a new session it shows me the Local repo in addition to CRAN and CRANextra. That said, I'm getting still getting errors, but at least they're different ones now. – Tommy O'Dell Dec 12 '12 at 04:16