rr-packageremotes

How to include subdirectory in `Remotes` field for R package `DESCRIPTION`


Let's say I want to use in my R package a development version of a dependency as it stands on a certain GitHub branch, but the additional complication is that it resides in a subdirectory.

For example, if I wanted to rely on the glmmTMB package from this branch, I can download it using remotes like so:

remotes::install_github("glmmTMB/glmmTMB@ci_tweaks", subdir = "glmmTMB")

If this package were not based in a subdirectory, I could have included the following in the DESCRIPTION file:

Remotes: glmmTMB/glmmTMB@ci_tweaks

But I don't know how to specify a subdirectory here to get the package.


Solution

  • You should know that remotes creates all needed DESCRIPTION file fields for you. So I run the remotes::install_github("glmmTMB/glmmTMB@ci_tweaks", subdir = "glmmTMB") and then packageDescription("glmmTMB"). Check out how many Remote and Github connected fileds are added. There is e.g. RemoteSubdir: glmmTMB too.

    > packageDescription("glmmTMB")
    Package: glmmTMB
    Title: Generalized Linear Mixed Models using Template Model Builder
    Version: 1.1.4
    Authors@R: c(person("Mollie","Brooks", comment=c(ORCID="0000-0001-6963-8326"), role =
              c("aut", "cre"), email = "mollieebrooks@gmail.com"), person("Ben","Bolker",
              role="aut", comment=c(ORCID="0000-0002-2127-0443")),
              person("Kasper","Kristensen",role="aut"), person("Martin","Maechler", role="aut",
              comment=c(ORCID="0000-0002-8685-9910")), person("Arni","Magnusson", role="aut",
              comment=c(ORCID="0000-0003-2769-6741")), person("Maeve","McGillycuddy",
              role="ctb"), person("Hans","Skaug",role="aut"), person("Anders","Nielsen",
              role="aut", comment=c(ORCID="0000-0001-9683-9262")), person("Casper","Berg",
              role="aut", comment=c(ORCID="0000-0002-3812-5269")), person("Koen","van Bentham",
              role="aut"), person("Nafis","Sadat",role="ctb",
              comment=c(ORCID="0000-0001-5715-616X")), person("Daniel","Lüdecke", role="ctb",
              comment=c(ORCID="0000-0002-8895-3206")), person("Russ","Lenth", role="ctb"),
              person("Joseph", "O'Brien", role = "ctb", comment = c(ORCID =
              "0000-0001-9851-5077")), person("Charles J.","Geyer", role="ctb"),
              person("Mikael","Jagan", role="ctb", comment = c(ORCID = "0000-0002-3542-2938")),
              person("Brenton", "Wiernik", role="ctb", comment = c(ORCID =
              "0000-0001-9560-6336")) )
    Description: Fit linear and generalized linear mixed models with various extensions,
              including zero-inflation. The models are fitted using maximum likelihood
              estimation via 'TMB' (Template Model Builder). Random effects are assumed to be
              Gaussian on the scale of the linear predictor and are integrated out using the
              Laplace approximation. Gradients are calculated using automatic differentiation.
    License: AGPL-3
    Depends: R (>= 3.2.0)
    Imports: methods, TMB (>= 1.7.14), lme4 (>= 1.1-18.9000), Matrix, nlme, numDeriv
    LinkingTo: TMB, RcppEigen
    Suggests: knitr, rmarkdown, testthat, MASS, lattice, ggplot2 (>= 2.2.1), mlmRev, bbmle (>=
              1.0.19), pscl, coda, reshape2, car (>= 3.0.6), emmeans (>= 1.4), estimability,
              DHARMa, multcomp, MuMIn, effects (>= 4.0-1), dotwhisker, broom, broom.mixed, plyr,
              png, boot, texreg, xtable, huxtable, mvabund
    SystemRequirements: GNU make
    VignetteBuilder: knitr, rmarkdown
    URL: https://github.com/glmmTMB/glmmTMB
    LazyData: TRUE
    BugReports: https://github.com/glmmTMB/glmmTMB/issues
    NeedsCompilation: yes
    Encoding: UTF-8
    RoxygenNote: 7.1.2
    RemoteType: github
    RemoteHost: api.github.com
    RemoteRepo: glmmTMB
    RemoteUsername: glmmTMB
    RemoteRef: ci_tweaks
    RemoteSha: fd8bb78acd8b198147285ce94b1f67043349f570
    RemoteSubdir: glmmTMB
    GithubRepo: glmmTMB
    GithubUsername: glmmTMB
    GithubRef: ci_tweaks
    GithubSHA1: fd8bb78acd8b198147285ce94b1f67043349f570
    GithubSubdir: glmmTMB
    Packaged: 2022-06-18 19:33:52 UTC; maciejnasinski
    Author: Mollie Brooks [aut, cre] (<https://orcid.org/0000-0001-6963-8326>), Ben Bolker [aut]
              (<https://orcid.org/0000-0002-2127-0443>), Kasper Kristensen [aut], Martin
              Maechler [aut] (<https://orcid.org/0000-0002-8685-9910>), Arni Magnusson [aut]
              (<https://orcid.org/0000-0003-2769-6741>), Maeve McGillycuddy [ctb], Hans Skaug
              [aut], Anders Nielsen [aut] (<https://orcid.org/0000-0001-9683-9262>), Casper Berg
              [aut] (<https://orcid.org/0000-0002-3812-5269>), Koen van Bentham [aut], Nafis
              Sadat [ctb] (<https://orcid.org/0000-0001-5715-616X>), Daniel Lüdecke [ctb]
              (<https://orcid.org/0000-0002-8895-3206>), Russ Lenth [ctb], Joseph O'Brien [ctb]
              (<https://orcid.org/0000-0001-9851-5077>), Charles J. Geyer [ctb], Mikael Jagan
              [ctb] (<https://orcid.org/0000-0002-3542-2938>), Brenton Wiernik [ctb]
              (<https://orcid.org/0000-0001-9560-6336>)
    Maintainer: Mollie Brooks <mollieebrooks@gmail.com>
    Built: R 4.2.0; aarch64-apple-darwin20; 2022-06-18 19:33:53 UTC; unix
    
    -- File: /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/glmmTMB/Meta/package.rds