Re: [Rd] generic function argument list problem

From: Martin Maechler <maechler_at_stat.math.ethz.ch>
Date: Wed 31 Aug 2005 - 07:30:37 GMT

>>>>> "Robin" == Robin Hankin <r.hankin@noc.soton.ac.uk>
>>>>> on Wed, 31 Aug 2005 08:09:15 +0100 writes:

    Robin> Hi it says in R-exts that

  1. A method must have all the arguments of the generic, including ... if the generic does.
  2. A method must have arguments in exactly the same order as the generic.
  3. A method should use the same defaults as the generic.
    Robin> So, how come the arguments for rep() are (x, times, ...) and the  
    Robin> arguments
    Robin> for rep.default() are  (x, times, length.out, each, ...) ?  Shouldn't  
    Robin> these be the same?

no. If they should be the same, the "R-exts" manual would use a much shorter formulation than the carefully crafted points 1--3 above!

The point is that methods often have *extra* arguments which match the "..." of the generic.
That's one of the points about "..." !

Martin Maechler, ETH Zurich

    Robin> I am writing a rep() method for objects with class "octonion", and
    Robin> my function rep.octonion() has argument list (x, times, length.out,  
    Robin> each, ...)
    Robin> just like rep.default(),   but  R CMD check complains about it, pointing
    Robin> out that rep() and rep.octonion() have different arguments.

    Robin> What do I have to do to my rep.octonion() function to make my package     Robin> pass R CMD check without warning?

    Robin> --
    Robin> Robin Hankin
    Robin> Uncertainty Analyst
    Robin> National Oceanography Centre, Southampton
    Robin> European Way, Southampton SO14 3ZH, UK
    Robin> tel  023-8059-7743

    Robin> ______________________________________________
    Robin> R-devel@r-project.org mailing list     Robin> https://stat.ethz.ch/mailman/listinfo/r-devel
    Robin>      A method must have all the arguments of the
    Robin> generic, including ... if the generic does.  A method
    Robin> must have arguments in exactly the same order as the
    Robin> generic.  A method should use the same defaults as
    Robin> the generic.


    Robin> So, how come the arguments for rep() are (x, times,
    Robin> ...) and the arguments for rep.default() are (x,
    Robin> times, length.out, each, ...) ? Shouldn't these be     Robin> the same?
    Robin> I am writing a rep() method for objects with class
    Robin> "octonion", and my function rep.octonion() has
    Robin> argument list (x, times, length.out, each, ...)  just
    Robin> like rep.default(), but R CMD check complains about
    Robin> it, pointing out that rep() and rep.octonion() have
    Robin> different arguments.

    Robin> What do I have to do to my rep.octonion() function to     Robin> make my package pass R CMD check without warning?

    Robin> -- Robin Hankin Uncertainty Analyst National
    Robin> Oceanography Centre, Southampton European Way,
    Robin> Southampton SO14 3ZH, UK tel 023-8059-7743

    Robin> ______________________________________________
    Robin> R-devel@r-project.org mailing list     Robin> https://stat.ethz.ch/mailman/listinfo/r-devel

R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Wed Aug 31 17:36:05 2005

This archive was generated by hypermail 2.1.8 : Mon 20 Feb 2006 - 03:21:19 GMT