Skip to content
Prev 2163 / 12125 Next

[R-pkg-devel] Conditionally register method with generic in other package

Bill, Duncan,

Thanks for the replies.

On Wed, Dec 6, 2017 at 12:51 PM, Duncan Murdoch
<murdoch.duncan at gmail.com> wrote:
While perhaps not technically illegal, that doesn't work because you need

if (requireNamespace("A", quietly = TRUE)) {
  importFrom(A, foo)
  S3method(foo, bar)
}

to prevent an error about being able to find object 'foo' when loading
B's namespace.  But the importFrom() causes R CMD check to expect a
hard dependency on package A (and all its dependencies), which is what
I'm trying to avoid...