Re: [Rd] generic function argument list problem

From: Jari Oksanen <>
Date: Wed 31 Aug 2005 - 08:04:42 GMT

On Wed, 2005-08-31 at 08:09 +0100, Robin Hankin wrote:
> Hi
> it says in R-exts 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.
> A method should use the same defaults as the generic.
> So, how come the arguments for rep() are (x, times, ...) and the
> arguments
> for rep.default() are (x, times, length.out, each, ...) ?
> these be the same?
> I am writing a rep() method for objects with class "octonion", and
> my function rep.octonion() has argument list (x, times, length.out,
> each, ...)
> just like rep.default(), but R CMD check complains about it,
> out that rep() and rep.octonion() have different arguments.
> What do I have to do to my rep.octonion() function to make my package
> pass R CMD check without warning?
I cannot repeat your problem. Probably you did something differently than you said (like omitted "..." , misspelled times as time or something else in your rep.octonion).

This is what I tried.

In R:
> str(rep)

function (x, times, ...)
> rep.octonion <- function(x, times, length.out, each, ...) {}
> package.skeleton("octonion", "rep.octonion")
Creating directories ...
Creating DESCRIPTION ...
Creating READMEs ...
Saving functions and data ...
Making help files ...
Created file named './octonion/man/rep.octonion.Rd'. Edit the file and move it to the appropriate directory. Done.
Further steps are described in ./octonion/README

Then I edited octonion/man/rep.octonion.Rd so that it uses the generic and passes R CMD check (virgin Rd files produced by package.skeleton fail the test, which I found a bit weird). Here are the minimum changes you need to pass the tests.

-\seealso{ ~~objects to See Also as \code{\link{~~fun~~}}, ~~~ } +
+\seealso{ ~~objects to See Also as \code{\link{rep}}, ~~~ }  \examples{
 ##---- Should be DIRECTLY executable !! ---- @@ -42,4 +42,4 @@
 function(x, time, length.out, each, ...) {}  }

-\keyword{ ~kwd1 }% at least one, from doc/KEYWORDS
-\keyword{ ~kwd2 }% __ONLY ONE__ keyword per line
+\keyword{ models }% at least one, from doc/KEYWORDS

So this replaces rep.octonion with \method{rep}{octonion}, removes __ from description (these cause latex errors), remove a hanging top level text "Make other sections...", and removes a link to non-existent ~~fun~~ (I'm not sure if adding a real keyword is necessary).

This passes tests. Including

Conclusion: check your files. (It is pain: been there, done that.)

cheers, jari oksanen mailing list Received on Wed Aug 31 18:08:26 2005

This archive was generated by hypermail 2.1.8 : Mon 24 Oct 2005 - 22:27:46 GMT