[Rd] Imports/exports of S4 methods

From: Roger D. Peng <rpeng_at_jhsph.edu>
Date: Thu, 03 May 2007 17:13:49 -0400

I have a question about what to do in the following situation (please bear with the setup):

Package A defines an S4 generic 'foo' and as well as S4 methods for 'foo' and has


in its NAMESPACE file.

Package B defines another method for 'foo' for class "bar" and has

importFrom(A, "foo")

in its NAMESPACE file. Should Package B also have Package A in the 'Depends:' field of the DESCRIPTION file or is it correct to import Package A only?

Finally, Package C has a single exported function named 'myfunc' which needs to use the method for 'foo' defined in Package B, so its NAMESPACE file has

importFrom(A, "foo")
importMethodsFrom(B, "foo")
importClassesFrom(B, "bar")

Is this the correct thing to do?

The error I get under this setup is that 'myfunc' cannot find the method for 'foo' defined in Package B when 'myfunc' calls 'foo' on an object of class "bar".

If you've made it this far I'm already grateful! Any help with this would be appreciated.


Roger D. Peng  |  http://www.biostat.jhsph.edu/~rpeng/

R-devel_at_r-project.org mailing list
Received on Thu 03 May 2007 - 22:15:31 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 04 May 2007 - 19:33:41 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.