Skip to content
Prev 2162 / 12125 Next

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

On 06/12/2017 8:44 AM, Bill Denney wrote:
It's usually better to use requireNamespace("A") instead of require("A") 
(and the quotes are needed in requireNamespace(), but optional in 
require()). That tries to load the package, but doesn't mess with the 
search list.

But that'll likely cause warnings, unless the same condition is used in 
the NAMESPACE file where there should be an entry

S3method(foo, bar)

The thing is, I'm not sure if

if (requireNamespace("A"))
   S3method(foo, bar)

is legal in a NAMESPACE file.

Duncan Murdoch