Bangyou
Bangyou

Reputation: 9816

How to setup a local repository for packrat?

I am using packrat_0.4.3 and have some my own packages.

I follow this introduction to create a local repository: http://cran.r-project.org/doc/manuals/R-admin.html#Setting-up-a-package-repository, then use this command to init packrat:

packrat::init(options = list(local.repos = c("~/Projects/www/htdocs/R/src/contrib/")))

But packrat still cannot find my local packages.

How should I fix it? Thanks for any suggestion.

Upvotes: 3

Views: 1111

Answers (1)

rmg
rmg

Reputation: 1089

The reference cited describes how to set up a CRAN like repository, however for packrat this is not required, you can just create a local directory.

Try this:

mkdir ~/local_repo
cp my_package ~/local_repo

So that local_repo looks like:

local_repo/
  my_package/
    R/
    ...

Then in R:

packrat::init()
packrat::set_opts(local.repos = c("~/local_repo"))
packrat::install_local('my_package')

If some tries this and runs into issues, let me know. I'm happy to amend the answer until this is resolved.

Upvotes: 1

Related Questions