[Rd] setMethod("c") [was: setMethod("Summary")]

From: Robin Hankin <r.hankin_at_noc.soton.ac.uk>
Date: Tue 05 Sep 2006 - 14:48:53 GMT

Hello everybody.

I didn't see Franklin's first message; sorry.

Bearing in mind Professor Ripley's comments on the efficiency of S4 vs S3, I'm beginning to think I   should just stick with S3 methods for my brob objects. After all, S3 was perfectly adequate for the onion package.

Notwithstanding that, here's my next problem. I want to define a brob method for "c". Using the example in package "arules" as a template (I couldn't see one in Matrix), I have


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

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

"brob" <- function(x,positive){

     positive <- rep(TRUE,length(x))

     positive <- rep(positive,length(x))


setGeneric("getX",function(x){standardGeneric("getX")}) setGeneric("getP",function(x){standardGeneric("getP")}) setMethod("getX","brob",function(x){x@x}) setMethod("getP","brob",function(x){x@positive})


           function(x, ..., recursive=FALSE){
             xx <- x@x
             xpos <- x@positive
             z <- list(...)

Now, this works for something like

 > x <- new("brob",x=pi,positive=T)
 > c(x,x)

but c(1,x) isn't dispatched to my function. How to deal cleanly with this case? Perhaps if any argument to c() is a brob object, I would like to coerce them all to brobs. Is this possible?

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
Received on Wed Sep 06 00:56:59 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:29 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.