[R-pkg-devel] install from github
Rainer M Krug
Rainer at krugs.de
Thu Dec 3 10:00:15 CET 2015
Berry Boessenkool <berryboessenkool at hotmail.com> writes:
> 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?
Check out drat [https://github.com/eddelbuettel/drat] and for a
description check out
Be aware that I have never used it - but I should...
> 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, "/")[] # 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, ", ")[]
> 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]]
> R-package-devel at r-project.org mailing list
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany)
Centre of Excellence for Invasion Biology
Tel : +33 - (0)9 53 10 27 44
Cell: +33 - (0)6 85 62 59 98
Fax : +33 - (0)9 58 10 27 44
Fax (D): +49 - (0)3 21 21 25 22 44
email: Rainer at krugs.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 454 bytes
Desc: not available
More information about the R-package-devel