Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

install.packages errors: Troubleshooting local repo usage

Tags:

r

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?

like image 488
Tommy O'Dell Avatar asked Dec 11 '12 05:12

Tommy O'Dell


Video Answer


2 Answers

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")
like image 186
Cedric Bovar Avatar answered Sep 19 '22 19:09

Cedric Bovar


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 
like image 36
agstudy Avatar answered Sep 19 '22 19:09

agstudy