Dear Franklin
thank you for this. Your suggestion works. But now I'm confused because I'm not sure how the setGeneric() call actually helps. If I source: setClass("brob", representation = representation (x="numeric",positive="logical"), prototype = list(x=numeric(),positive=logical()) ) max.brob <- function(..., na.rm=FALSE){stop("not YET implemented")} ---ie no call to setGeneric()--- then in an R session I can do the following: R> x <- new("brob",x=6,positive=T) R> max(x) Error in max.brob(..., na.rm = na.rm) : not YET implemented So max(x) calls max.brob() as intended. Why would a call to setGeneric() be desirable here? What do I gain from it? thanks again Robin On 4 Sep 2006, at 19:58, Parlamis Franklin wrote: > i believe, if the function you are trying to work with has "..." as > the first formal argument (as do most if not all of the "Summary" > group functions), you will need to redefine the generic in order to > provide a "real" S4 argument on which to dispatch. > > the following works for me (IIRC it was martin who initially pointed > me in this direction, so any thanks are his). > > setGeneric("max", function(x, ..., na.rm = FALSE) > { > standardGeneric("max") > }, > useAsDefault = function(x, ..., na.rm = FALSE) > { > base::max(x, ..., na.rm = na.rm) > }, > group = "Summary") > > i don't have bleeding edge devel version installed, so i am not sure > whether recent changes to S4 have mooted the above. > > (also, i thought i sent this last week, but i may have neglected to > make it plain text, so maybe you didn't get it) > > franklin parlamis > > On Sep 4, 2006, at 3:47 AM, Robin Hankin wrote: > >> Hi everyone and thanks for being patient. I've used "!.foo"() et >> seq pro tem. >> >> Next problem: how to define "Summary" methods for brobs. >> >> ?max says >> >> 'max' and 'min' are generic functions: methods can be defined for >> them individually or via the 'Summary' group generic. For >> this to >> work properly, the arguments '...' should be unnamed. >> >> OK, so what is the correct procedure to make sum() operate on brob >> objects? >> >> My best effort follows. >> [snipped] -- Robin Hankin Uncertainty Analyst National Oceanography Centre, Southampton European Way, Southampton SO14 3ZH, UK tel 023-8059-7743 ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel