Search code examples
rpackagedevtools

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.


Solution

  • 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))
        }