10

I want to set up a local CRAN repository . I want to put just one package in this repository ( let's call it MyPackage ). The reason I'm doing this is that I want to share this package with people at my company. By the way - we all use Ubuntu Linux. I have already done this:

  • I have a web server ( BOA web server ) and made a web folder called R. Made folder src and contrib.
  • In the contrib folder I put my package MyPackage ( tar.gz) plus the PACKAGES file.

However, when I do this:

install.packages("MyPackage", repos = "127.0.0.1/R" ) 

it does not work ;

Warning: unable to access index for repository [ ]
Warning message:
In getDependencies(pkgs, dependencies, available, lib) :
  package ‘MyPackage’ is not available (for R version 2.13.1)

Can you guys guide me a bit and tell me what is the correct folder structure ? Thanks.

MadSeb
  • 7,958
  • 21
  • 80
  • 121
  • The online repositories contain `built` R packages. You would need to `build` the package (which creates a `.tar.gz` file. Look at the directory structure of an online repository. [CSIRO melbourne](http://cran.csiro.au/src/contrib/). – mnel Aug 13 '12 at 01:51
  • 2
    If you don't mind the package being public you could always host it on github and use the function `install_github` from the devtools package to do the installation. This is quite easy to do and requires less work to make changes to the package. – Dason Aug 13 '12 at 02:20
  • Conversely you could use bitbucket which operates very similar to bit bucket. `install` from devtools has functionality similar to dason's suggestion but installs the local repo. Here's a youtube on how to do this: http://www.youtube.com/watch?v=jGeCCxdZsDQ but is way more than your question asked for. from 6:10 on it's pertinent to you. – Tyler Rinker Aug 13 '12 at 02:25
  • You're looking for more detail, but about what? That is, what in the FAQ is unclear? – Aaron left Stack Overflow Aug 20 '12 at 16:49
  • Hi guys, I followed the instructions in the FAQ and I just can't get it to work , spent several hours trying to set it up. – MadSeb Aug 20 '12 at 16:52

4 Answers4

13

See "Section 6.6 Setting up a package repository" of the R Admin manual.

Edit some three+ years later: We now have the drat package which automates creating a repository, and can use GitHub in a clever way to host it for you.

Dirk Eddelbuettel
  • 360,940
  • 56
  • 644
  • 725
5

You might just need to specify the URL properly; http://127.0.0.1/R.

Also, make sure you can access that URL in your browser.

Aaron left Stack Overflow
  • 36,704
  • 7
  • 77
  • 142
0

The miniCRAN works good for me. There are few advantages to using miniCRAN to create the repository:

  • Security: Many R users are accustomed to downloading and installing new R packages at will, from CRAN or one of its mirror sites.
  • Easier offline installation: To install package to an offline server requires that you also download all package dependencies, Using miniCRAN makes it easier to get all dependencies in the correct format.
  • Improved version management: In a multiuser environment, there are good reasons to avoid unrestricted installation of multiple package versions on the server.
  • Use other R Package Indexes: You may wish to make packages available from public repositories other than CRAN, e.g. BioConductor, r-forge, OmegaHat, etc.
  • Prepare own R repo: You may wish to add custom in-house packages to your repository.

See intro:

  1. Using miniCRAN to create a local CRAN repository
  2. Create a local package repository using miniCRAN
Community
  • 1
  • 1
korniichuk
  • 550
  • 1
  • 8
  • 13
0

I think the problem is revealed in this statement: "In the contrib folder I put ... the PACKAGES file."

The PACKAGES file is an index for the repository. You need to create that file after your package files are placed in the repository directory. Don't copy and paste the PACKAGES file from another repository.

If I were you, here's what I would do. First, add the following code to your .Rprofile for a local repository:

utils::setRepositories(ind = 0, addURLs = c(WORK = "127.0.0.1/R"))

Restart R after changing your .Rprofile.

ind = 0 will indicate that you only want the local repository. Additional repositories can be included in the addURLs = option and are comma separated within the character vector.

Then, create the repository index:

tools::write_PACKAGES("127.0.0.1/R/src/contrib", verbose = TRUE) 

After you do that, you should be able to generate a data frame that has a list of all the packages. For example, my_packages <- available.packages().

If you see packages in your repository data frame, then install using the following code:

install.packages("MyPackage")

For more information, please see here.

Ted M.
  • 182
  • 1
  • 8