Skip to content
Prev 2161 / 12125 Next

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

One simple solution would be to wrap the instantiation of foo.bar in a require test:

if (require(A)) {
  foo.bar <- function(...) {
    print("To be or not to be")
  }
} else {
  message("To use the foo.bar function, please install package A.")
}

Thanks,

Bill