[R] check WARNING...

Thomas Lumley tlumley at u.washington.edu
Tue Dec 2 16:12:53 CET 2003


On Mon, 1 Dec 2003, Jeff D. Hamann wrote:
> I have a function called
>
> plot.summaries <- function( trees, sp=NULL ) {
> ...yak, kay, yak...
> }
>
> and I'm not sure if this is causing the problem. I'm developing a package
> for forestry and the field makes use of many terms commonly found in
> technology (logs, trees, plots, points, etc) and would like to know if the
> nomenclature will cause a problem.
>

Yes, that's the problem. Yes, it's annoying.  Yes, there's a good reason
for it.

If you define a method for plot, it has to be compatible with the generic
and it has to be able to be extended if someone else develops a subclass
of your class. As long as no-one extends your code, and the function is
always called as  plot(some.tree.thing) there isn't a problem.  But if
someone calls
   plot(trees=some.tree.thing)
this doesn't match the generic.

If plot.summaries() isn't a method for plot then it should be called
something else, like plotSummaries().

	-thomas




More information about the R-help mailing list