[R] S3 generics need identical signature?

From: Gábor Csárdi <csardi_at_rmki.kfki.hu>
Date: Mon, 21 Jun 2010 15:31:01 +0200

Dear all,

"Writing R Extensions" explicitly says that

    A method must have all the arguments of the generic, including ... if the generic does.

    A method must have arguments in exactly the same order as the generic.     If the generic specifies defaults, all methods should use the same defaults.

This is clear. R CMD check even checks for this.

But then how is it possible that for plot(), which is an S3 generic, plot.default(), plot.formula() and plot.table(), etc. all have different arguments?

The question is not simply theoretical, I have two S3 generics in my package, and one is reported by R CMD check, but the other not, and I fail to see why the difference.

Moreover, R CMD check reports:
* checking S3 generic/method consistency ... WARNING plot:
  function(x, ...)
  function(communities, graph, colbar, col, mark.groups, layout,

           edge.color, ...)

But actually, the signature of plot() seems to be
> plot

function (x, y, ...)

I am confused. What am I missing?

Thanks, Best Regards,

Gabor Csardi <Gabor.Csardi_at_unil.ch>     UNIL DGM

R-help_at_r-project.org mailing list
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Mon 21 Jun 2010 - 13:36:05 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 Mon 21 Jun 2010 - 14:30:34 GMT.

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

list of date sections of archive