[R-pkg-devel] install from github

Berry Boessenkool berryboessenkool at hotmail.com
Thu Dec 3 09:40:12 CET 2015


is someone aware of a way to easily install a package hosted on github without using devtools::install_github?
Does anyone else ever need to avoid devtools?
Would something doing that be worth a package on CRAN?
Optional if no,yes,yes: Is my basic idea below any good at all?

Thanks ahead,
Berry, Potsdam, Germany


devtools has so many dependencies that it takes quite some time to install on old computers or with slow internet. Not suitable for a quick demo in the R course I'm teaching, which I found out the hard way (thinking R had hung up, I terminated it, crashing Rstudio in the proces...).
Not finding anything and happy to postpone actual work, I wrote some (very!) basic code. I doubt it works across platforms and situations. I guess I'm doing useless stuff, but I had fun and learned a few new things...

instgithub <- function(
   pk, # "user/package"
   cleanup=TRUE, # remove downloaded zipfile and folder with source code
   ...) # Further arguments passed to install.packages, untested so far
pkn <- strsplit(pk, "/")[[1]][2] # package name part
file.rename(paste0(pkn,"-master"), pkn)
# Dependencies - really not elegant at all!
deps <- read.dcf(paste0(pkn, "/DESCRIPTION"), fields="Imports")
deps <- strsplit(deps, ", ")[[1]]
deps <- sapply(strsplit(deps, " ", fixed=T), "[", 1) # remove version restrictions
deps <- deps[!deps %in% rownames(installed.packages())] # install only new packages
# install dependencies
dummy <- lapply(na.omit(deps), install.packages, ...)
# actually install the package itself:
install.packages(pkn, repos=NULL, type="source", ...)
# clean up:
  unlink(pkn, recursive=TRUE)

# example test cases, work fine on windows 7 with current R3.2.2 + write permission at getwd:

	[[alternative HTML version deleted]]

More information about the R-package-devel mailing list