Re: [R] S4 : setGeneric for classical methods

From: <cgenolin_at_u-paris10.fr>
Date: Sat, 26 Jul 2008 12:12:12 +0200

Martin Maechler <maechler_at_stat.math.ethz.ch> a écrit :

>>>>>> "CG" == Christophe Genolini <cgenolin@u-paris10.fr>
>>>>>> on Tue, 22 Jul 2008 19:04:37 +0200 writes:
>
> CG> Prof Brian Ripley <ripley_at_stats.ox.ac.uk> a écrit :
> >> On Tue, 22 Jul 2008, cgenolin_at_u-paris10.fr wrote:
> >>
> >>> Hi the list (well, half of the list, only the one who
> >>> are not on holidays...)
> >>>
> >>> I am trying to make an S4 package. When I run it on a
> >>> console, everything seems ok. When I run R CMD check, I
> >>> got an error --- 8<
> >>> ----------------------
> >>> Error in setMethod("plot", "ClassX", function(x, y) { :
> >>> no existing definition for function "plot" --- 8<
> >>> ----------------------
> >>>
> >>> If I add
> >>> setGeneric("plot",function(x,y,...){standardGeneric("plot")})
> >>> in my code, then everything is OK.
> >>>
> >>> This is a surprise for me since I taught that we do not
> >>> need to redefine as generic the function that are
> >>> already generic, like "plot". Am I wrong ?
> >>
> >> Yes. And do read the error message. It says
> >>
> >> no existing definition for function "plot"
> >>
> >> so this is not if the function is S3 or S4 generic, but
> >> that no such function is visible.
> >>
> >> Looks like you forgot to declare a dependence on (or
> >> import) package graphics.
>
> CG> I would have forgot if I knew that I have to declare
> CG> such a dependence... Do we have to declare all the
> CG> depence to all the package ? To base ? To stats ?
>
> not to base, but to all other packages (since R can be loaded
> without any packages but base).
>
> CG> I thaught that the package that are include in R when we
> CG> start it had not to be include.
>
> You thought wrongly, and all our documentation mentions that you
> need to use 'Depends:' correctly (and 'Imports(..)' in
> NAMESPACE if you make use of one).
>
> {and please strongly note the correct spelling of "thought" !}
>
> Martin

I correct DESCRIPTION and NAMESPACE adding Depends and import. But I still get the message :

checking for missing documentation entries ... WARNING Undocumented S4 methods:
  generic 'plot' and siglist 'ClassX'

I can't find what is wrong...

import(graphics)

Christophe



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 Sat 26 Jul 2008 - 10:34:23 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 Sat 26 Jul 2008 - 13:32:22 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