Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make R package recommend a package hosted on GitHub?

I'm developing an R package that works as a wrapper for functions from the parallel and Rhpc packages called ctools. I know that if I want my package to require these packages I need to include them in the Imports section of the DESCRIPTION file. When installing my package, these packages will be installed from CRAN. Similarly I can put them in the Suggests section if they aren't required, but useful. These won't be installed with my package.

But, I've forked the Rhpc package and added a function that I use in my ctools package. How do I get my package to Suggest/Import this package from my GitHub repo so of instead of installing the Rhpc package, it executes devtools::install_github("bamonroe/Rhpc")?

like image 525
Brian Albert Monroe Avatar asked Mar 19 '16 18:03

Brian Albert Monroe


People also ask

How do I connect a package to GitHub?

Connecting a repository to a user-owned package on GitHub In the top right corner of GitHub.com, click your profile photo, then click Your profile. On your profile page, in the top right, click Packages. Under your package versions, click Connect repository. Select a repository, then click Connect repository.


1 Answers

From the manual (and quoting source here):

@c DESCRIPTION field Additional_repositories

The @samp{Additional_repositories} field is a comma-separated list of repository URLs where the packages named in the other fields may be found. It is currently used by @command{R CMD check} to check that the packages can be found, at least as source packages (which can be installed on any platform).

You can add the package to Suggests: and point to additional repositories -- possibly created using drat. There used to a package doing that, and IIRC there is another one doing it now but its name escaped me now.

Edit: Found it! See here in the source DESCRIPTION file of RNeXML -- and note how the line disappears in the posted DESCRIPTION on CRAN. Better still, note how two of the packages in Suggests: are not listed a hyperlinks on CRAN. I thinks those come from the additional repos. And yes, rOpenSci uses drat to manage that.

Edit 2: And just to close the loop, you (easily) use drat to host such an additional repo on GitHub -- the prime use case for drat.

Edit 3: RNeXML has dropped the additional repository, but the github history still has it.

Edit 4: Currently (i.e. on 2020-03-13), the CRAN packages EMC, bcmaps, blkbox, broom.mixed, epikit, grattan, gtsummary, hurricaneexposure, memoise, multinomialeq, noaastormevents, pointblank, provSummarize, provViz, spData, swephR, tashu, taxadb, waveformbildar all list a field Additional_repositories containing a URL pointing to a drat repo.

like image 130
Dirk Eddelbuettel Avatar answered Oct 13 '22 02:10

Dirk Eddelbuettel