Search code examples
rcran

(How) can a package on CRAN import a package not on CRAN?


Packages on the Comprehensive R Archive Network (CRAN) can obviously directly import other packages that are on CRAN.

Can packages on CRAN also import packages that are not on CRAN? - if not, I guess the options are:

  • get the other package onto CRAN, or
  • abstract out the necessary parts to include directly (rather than import the entire package)
  • other methods?

I'm interested because sometimes a contribution makes more sense sitting in a separate package, especially if the contribution is likely to be used in its own right, or in other packages.


Solution

  • I don't think so.

    Writing R Extensions specifies that you can include an Additional_repositories field in the DESCRIPTION file.

    However, the CRAN Repository Policy says:

    Packages on which a CRAN package depends should be available from a mainstream repository: if any mentioned in ‘Suggests’ or ‘Enhances’ fields are not from such a repository, where to obtain them at a repository should be specified in an ‘Additional_repositories’ field of the DESCRIPTION file (as a comma-separated list of repository URLs) or for other means of access, described in the ‘Description’ field.

    • "mainstream" here presumably means CRAN (and maybe? Bioconductor) (this bioc-devel thread from 2015 suggests that both CRAN and Bioconductor are "mainstream")
    • "depends" here means Imports/LinkingTo/Depends

    I can't think of any solutions beyond the ones you suggest (get the package on CRAN or incorporate the necessary code in your package).