[R-pkg-devel] install from github

Mark van der Loo mark.vanderloo at gmail.com
Thu Dec 3 11:50:36 CET 2015


>> is someone aware of a way to easily install a package hosted on github
without using devtools::install_github?

Personally, I love Dirk's[1] drat package. It allows authors to set up a
personal CRAN-like system on their github pages. This means that the author
of the package can decide when a (beta) release of a package is ready for
use. I use it frequently, for example to allow people to confirm bug fixes
prior to resubmitting to CRAN.

>> Does anyone else ever need to avoid devtools?

I love devtools, but avoid install_github. Be aware that installing from
github does require some knowledge of the (directory) structure of the
repo, which not necessarily is that of a package. For example, in my
R-package repos, the package is always behind a pkg/[pkgname] folder. Besides
that you can't be sure that a package downloaded from github actually
builds (unless the author uses a build service), there are issues with
documentation. install_github for example presumes that all Rd files are in
the repo[2]. As these are nowadays mostly generated by Roxygen2, I feel
such files do not belong there and since the creation of Roxygen I've left
them out. Other authors might do the same.

I also wonder about the use case of install_github in an R-course. The
courses I teach never depend on software that are in an experimental stage
(there's enough to teach on CRAN)

>> Would something doing that be worth a package on CRAN?

I agree with the dependency issue, so in that sense yes. But to make it
robust, repo-owners probably need to adhere to either a pure R package
structure or start using makefiles for package building.


Best,
Mark

[1] When I say Dirk, I assume you know which one :-).
[2] At least, this used to be true. I haven't used it in a while.









Op do 3 dec. 2015 om 10:01 schreef Rainer M Krug <Rainer at krugs.de>:

> 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
> ______________________________________________
> R-package-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel

	[[alternative HTML version deleted]]



More information about the R-package-devel mailing list