Re: [R] S3 generics need identical signature?

From: Henrik Bengtsson <hb_at_stat.berkeley.edu>
Date: Mon, 21 Jun 2010 17:42:29 +0200

On Mon, Jun 21, 2010 at 4:23 PM, Gábor Csárdi <csardi_at_rmki.kfki.hu> wrote:
> On Mon, Jun 21, 2010 at 4:17 PM, Duncan Murdoch
> <murdoch.duncan_at_gmail.com> wrote:
> [...]
>> The requirement is that the methods need to have signatures that contain all
>> the arguments of the generic.  If the generic includes ..., then the methods
>> can add other arguments, too.  So with the generic for plot() as you show
>> above, any plot method is required to have x and y as the first two
>> arguments, and ... as an argument, but they can have other args too.
>
> This makes sense, and it is actually great! Thanks a lot for the explanation.

FYI, the most "generic" way you can write a generic function is:

foo <- function(...) UseMethod("foo");

/Henrik
>
> Best Regards,
> Gabor
>
> [...]
>
>
> --
> Gabor Csardi <Gabor.Csardi_at_unil.ch>     UNIL DGM
>
> ______________________________________________
> R-help_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help 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 - 15:47:14 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 - 16:50:33 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