Suraj
Suraj

Reputation: 36547

Package dependencies when installing from source in R

Just confirming: If I distribute my R package as ZIP/TAR then installing the package will not automatically download/install dependencies because I have to set repos = NULL in install.packages() and dependencies parameter is not used if repos = NULL? The way to possibly get this to work is to package an install script. Is that possible? Am I completely missing something here and there is a mechanism to install from source AND automagically download and install dependencies?

Upvotes: 23

Views: 6831

Answers (4)

Brandon Loudermilk
Brandon Loudermilk

Reputation: 970

If you have a Github account myname, push your R package to a repo mypackage. Then just call devtools::install_github("myname/mypackage"). Package mypackage will be downloaded and installed as will all the dependencies listed under Imports in the DESCRIPTION file.

Upvotes: 0

Yukun
Yukun

Reputation: 325

You can use

  devtools::install_local(path)

It can automatically download all the dependencies.

Upvotes: 5

sebastian-c
sebastian-c

Reputation: 15395

The devtools package has a function install. If used on a directory containing the source code for an R package, it will install that package and download any dependencies from CRAN.

Upvotes: 10

Aaron - mostly inactive
Aaron - mostly inactive

Reputation: 37754

You could make your own repository and set repos to be a vector of the places to look for packages, where it would start with your own repository and then include a link to a CRAN mirror. This is what I do and it works quite nicely, as then I can easily share my packages with others and update them from whatever computer I happen to be on.

Upvotes: 9

Related Questions