[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:
> Hi,
>
> 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?
Hi,
Check out drat [https://github.com/eddelbuettel/drat] and for a
description check out
[http://eddelbuettel.github.io/drat/DratForPackageAuthors.html].
Be aware that I have never used it - but I should...
Cheers,
Rainer
> 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
>
> Details:
>
> 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
> download.file(url=paste0("https://github.com/",pk,"/archive/master.zip"),
> destfile=paste0(pkn,".zip"))
> unzip(paste0(pkn,".zip"))
> 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:
> if(cleanup)
> {
> unlink(pkn, recursive=TRUE)
> unlink(paste0(pkn,".zip"))
> }
> }
>
> # example test cases, work fine on windows 7 with current R3.2.2 + write permission at getwd:
> if(FALSE){
> instgithub(pk="brry/extremeStat")
> library(extremeStat)
> instgithub("talgalili/installr")
> instgithub("hadley/readxl")
> }
>
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-package-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel
--
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany)
Centre of Excellence for Invasion Biology
Stellenbosch University
South Africa
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
Skype: RMkrug
PGP: 0x0F52F982
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 454 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-package-devel/attachments/20151203/309435f1/attachment.bin>
More information about the R-package-devel
mailing list