[R] c(...) and methods

Marsland, John John.Marsland at CommerzbankIB.com
Tue Jun 10 14:23:35 CEST 2003


I have been writing some S4 classes and have a problem about how I might
pass a signature to "c()".

Take the following example:

setClass("collection", representation("list", date="POSIXt"))

x <- new("collection", list(1,2,3), date=Sys.time())
y <- new("collection", list(4,5,6), date=Sys.time())

obviously, I can do c(x,y), but this wil be of class "list"

I would like to do something like:

setMethod("c", signature("collection"),
    function(...) {
        if(e1 at date!=e2 at date) stop("at different dates!")
        res <- c(as(e1, "list"),as(e2, "list"))
        new("collection", res, date = e1 at date)
        })

but c() takes "..." as its arguments and I don't know how I might reference
that with a signature and appropriate arguments etc.

Has anybody an ideas? I presume it doesn't matter that c() is
.Primative("c")?

Regards, 

John Marsland


********************************************************************** 
This is a commercial communication from Commerzbank AG.\ \ This ... {{dropped}}




More information about the R-help mailing list