[R] S3 generics need identical signature?
hb at stat.berkeley.edu
Mon Jun 21 17:42:29 CEST 2010
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");
> 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.
More information about the R-help