Do I need to export functions conditionally imported via :: in R?

I extract information from objects whose classes are defined in different R-packages. For example, I extract coefficients from various statistical models (for which coefficient methods are not always implemented). I usually do not need to import these packages because I have defined a common function for which methods can be added by users. There is one method for each type of statistical model, and it would be foolish to import all these model definitions if the user is interested in only one specific type of model.

In some cases, however, I need to use the function defined in the package. For example, the confint.merMod method in the lme4 package. So far I have used package::function to call these functions and wrapped this command in exists(function) if-condition to make sure that the package really offers this function (since the function may be available only in some versions of the package).

However, I just discovered at http://developer.r-project.org/blosxom.cgi/R-devel/NEWS (see September 5, 2013) that in R version 3.0.2, "R CMD validation does more thorough checking of declared packages and namespaces. It tells objects [...] imported ':: which are not exported.

Does this mean that I really need to add export("function") to the NAMESPACE file? Will the CMD check complain because the function is imported conditionally only?

+4
source share
1 answer

To clarify / summarize future visitors ...

The R-devel news cites a question related to the current NEWS 3-0 file, where a specific entry lists specific cases in which the R CMD check will generate a report for problems detected by importing, using, and declaring packages and functions.

If you have questions regarding a specific warning, the list is worth a look.

For more (and more detailed) information, see the r wiki page for links to the WRR Extensions development guide and other useful information.

+2
source

Source: https://habr.com/ru/post/1501843/


All Articles