Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install some parts from Github when calling "install.packages()" in R

Tags:

github

r

cran

I'd like to put a package onto CRAN. However, the package currently uses an external C model (ISDA Standard model), which is created under public re-distributable license. However, the CRAN administrator refuses to put the package on CRAN if it contains this C model. So is there anyway to put the package onto CRAN without this C model, and when calling install.packages("my.package"), it can automatically download the C model from github.com/my_github?

For now, I wrote the following code in zzz.R:

.onLoad <- function(libname, pkgname) {
    if ( ! "Github_pkg" %in% (all.available = TRUE)){
        devtools::install_github("myGithub/Github_pkg")
    }
} 

Is this okay if I submit to CRAN? Or should I use drat package by Dirk? Thanks!!

like image 753
Miller Zhu Avatar asked Jun 03 '15 12:06

Miller Zhu


People also ask

How do I install more than one package in R?

You can install multiple packages by passing a vector of package names to the function, for example, install. packages(c("dplyr", "stringr")) . That function will install the requested packages, along with any of their non-optional dependencies.


1 Answers

You can look into my drat package to create your own repository on GitHub. I use that for example to host the Rblpapi package I contribute to (and which relies on a library from Bloomberg) in this ghrr repository built using drat.

This all works. CRAN has even accepted a package which used the ghrr drat repo as an external repository (but since removed that package for another reason).

You still need to organize your "primary" package on CRAN in such a way that the "secondary" package is only a "Suggests:" as actual dependencies must be on CRAN too. But at least this gives you a way to automate these processes.

like image 96
Dirk Eddelbuettel Avatar answered Sep 29 '22 12:09

Dirk Eddelbuettel