Build a package import a non-exported function from a imported package

I am learning to develop a package.

  1. When I want to import a function from a non-exported function from a imported package, like blogdown:::scan_yaml, I always get this warning, object ‘scan_yaml’ is not exported by 'blogdown'
  2. If I change #' import blogdown to #' importFrom blogdown scan_yaml, I will get this error.
    Error : object ‘scan_yaml’ is not exported by 'namespace:blogdown'

How can I import this function in a correct way?

I think you can't do it cleanly. I think this is why you have a warning because it is really not advice, (and not allowed for CRAN :package:) to import in your package a non exported function from another package.
You can ask for the function to be exported, rewrite a similar function or if licence is ok and by respecting it, get the code in your package.

Follow the advice from R Packages (2e) - 4  Fundamental development workflows

Similarly you are not allowed to use ::: to access non-exported functions from other packages. Either ask the package maintainer to export the function you need, or write your own version of it using exported functions. Alternatively, if the licenses are compatible you can copy and paste the exported function into your own package. If you do this, remember to update Authors@R .

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.