[Rd] setMethod("Summary")

From: Robin Hankin <r.hankin_at_noc.soton.ac.uk>
Date: Mon 04 Sep 2006 - 13:47:29 GMT


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.

setClass("brob",

          representation = representation (x="numeric",positive="logical"),

          prototype      = list(x=numeric(),positive=logical())
          )


.Brob.max <- function(...){

   stop("not yet impemented")
}

setMethod("Summary", signature("brob"),

           function(...){
             switch(.Generic,
                    max    =  .Brob.max(...),
                    stop(paste(.Generic, "not implemented yet "))
                      )
           }

)

but this gives an error from conformMethod().

[I've left the arguments to signature() unnamed because ? GenericFunctions
says

          A signature is
           a named or unnamed vector of character strings.  If named,
           the names must be formal argument names for the generic
           function.  If 'signature' is unnamed, the default is to use
           the first 'length(signature)' formal arguments of the
           function.

which seems to tell me (in conjunction with the advice from Extremes.Rd quote above)
to use unnamed arguments to signature()
]

What is the correct way to make sum(x) call .Brob.max() if x is a "brob" object?
Or is is it better to define a sum.brob() function and use that?

--
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
Received on Mon Sep 04 23:56:32 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 06 Sep 2006 - 11:39:24 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.