Reputation: 8254
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:
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.
Upvotes: 10
Views: 5205
Reputation: 392
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.
Upvotes: 0
Reputation: 600
The miniCRAN works good for me. There are few advantages to using miniCRAN to create the repository:
See intro:
Upvotes: 2
Reputation: 368509
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.
Upvotes: 13
Reputation: 37804
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.
Upvotes: 5