[R] S3 generics need identical signature?

Gábor Csárdi csardi at rmki.kfki.hu
Mon Jun 21 15:31:01 CEST 2010


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, ...)
plot.communities:
  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

-- 
Gabor Csardi <Gabor.Csardi at unil.ch>     UNIL DGM



More information about the R-help mailing list