Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Include github packages as imports in DESCRIPTION

I'm using devtools and I have some packages on github. I would like to create dependencies between them, so when I run install_github(...) the other github packages that are in the DESCRIPTION file listed as Imports will also be installed. Can I do this or is there another thing people do?

Currently if I add a package to Imports that isnt available on CRAN I simply get a message "Skipping ... packages not available: xxx" when I run install_github.

like image 543
Rorschach Avatar asked Jan 07 '23 04:01

Rorschach


2 Answers

You can add a github dependency in the DESCRIPTION file with Remotes: like this:

Imports:
    mypackage
Remotes:
    mygithub/mypackage

See https://cran.r-project.org/web/packages/devtools/vignettes/dependencies.html for how to add non-github dependencies.

like image 182
Lisa DeBruine Avatar answered Jan 15 '23 08:01

Lisa DeBruine


Trying to get R's package loaders to install from github sounds like a rabbit hole.

Instead, use something like this in your package's .onload() method.

# install these from github, not CRAN:
pkglist <- list(
    c(name='ggplus',url='guiastrennec/ggplus'),
    c(name='DT',url='rstudio/DT'))

for(pkg in pkglist)
    if(!suppressWarnings(suppressPackageStartupMessages(require(pkg['name'],
        quietly=TRUE,character.only=TRUE)))){
        devtools::install_github(pkg['url'])
        suppressPackageStartupMessages( library(pkg['name'],character.only=TRUE))
    }
like image 26
Jthorpe Avatar answered Jan 15 '23 07:01

Jthorpe