Using un-exported function from another R package?

  • Summarising comments from @baptise, and etc...:

  • ::: not allowed on CRAN, so options:

    1. ask author to export it so you can use it in your package via standard imports or suggests.
    2. copy / lift a version of it and clearly cite within your package.

Another trick is using getFromNamespace():

fun <- utils::getFromNamespace("fun", "pkg")

The only advantage over ::: is that you don't get any NOTEs and it's allowed on CRAN. Of course, this is not good practice as a hidden change in pkg can break your package.

Note: With roxygen2 you have to add the utils package to the Imports field of your DESCRIPTION file to fulfill CRAN's requirements. Alternatively, you can put it in your NAMESPACE manually.

Tags:

R

Cran