[R-pkg-devel] installing packages from github

Dirk Eddelbuettel edd at debian.org
Mon Sep 4 16:54:36 CEST 2017


On 4 September 2017 at 14:22, Berry Boessenkool wrote:
| - do I miss something obvious?

The part where devtools has been undergoing a renovation for some time now
splitting functionality into many small packages?

I have my own views on repos with clearly marked and explicitly prepared
releases versus 'installing random commit snapshots from GH' -- but sometimes
you need the latter and I tend to use the helper below at the shell prompt.
It switches to using remotes quite some time ago.

Dirk


#!/usr/bin/env r
#
# A simple example to install one or more packages from GitHub
#
# Copyright (C) 2014 - 2016  Carl Boettiger and Dirk Eddelbuettel
#
# Released under GPL (>= 2)

## load docopt and remotes (or devtools) from CRAN
suppressMessages(library(docopt))       # we need docopt (>= 0.3) as on CRAN
suppressMessages(library(remotes))      # can use devtools as a fallback

## configuration for docopt
doc <- "Usage: installGithub.r [-h] [-x] [-d DEPS] [-u UPDATE] [REPOS...]

-d --deps DEPS       install suggested dependencies as well? [default: NA]
-u --update UPDATE   update dependencies? [default: TRUE]
-h --help            show this help text
-x --usage           show help and short example usage"

opt <- docopt(doc)			# docopt parsing

if (opt$usage) {
    cat(doc, "\n\n")
    cat("where REPOS... is one or more GitHub repositories.

Examples:
  installGithub.r RcppCore/RcppEigen                     

installGithub.r is part of littler which brings 'r' to the command-line.
See http://dirk.eddelbuettel.com/code/littler.html for more information.\n")
    q("no")
}

## docopt parsing
opt <- docopt(doc)
if (opt$deps == "TRUE" || opt$deps == "FALSE") {
    opt$deps <- as.logical(opt$deps)
} else if (opt$deps == "NA") {
    opt$deps <- NA
}

opt$update <- as.logical(opt$update)

invisible(sapply(opt$REPOS, function(r) install_github(r, dependencies = opt$deps, upgrade = opt$update)))

-- 
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org



More information about the R-package-devel mailing list