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 ? Christophe
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. -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
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.I would have forgot if I knew that I have to declare such a dependence... Do we have to declare all the depence to all the package ? To base ? To stats ? I thaught that the package that are include in R when we start it had not to be include. Christophe