From r.hijmans at gmail.com  Wed Mar 11 15:45:35 2009
From: r.hijmans at gmail.com (Robert Hijmans)
Date: Wed, 11 Mar 2009 22:45:35 +0800
Subject: [Rd] generic method for median
Message-ID: <dc22b2570903110745w2960b0efm1ad625b2722c7a1d@mail.gmail.com>

Sorry, I pressed the wrong button (tab in gmail is tricky) , here is
my message again, now more complete, and with the right subject:

I would like to write an S4 generic for 'median', but I am not sure
how to do this properly as the function does not have a "..." argument

I can do this
setGeneric("median", function(x, na.rm=FALSE)
 ? ? ? ?standardGeneric("median"))

 but I want to be able to pass it a number of objects of the same
 class, so I need a ... argument; or use signature='list' which is not
 very useful.

 I can do this:

 setGeneric("median", function(x, ..., na.rm=FALSE)
 ? ? ? ?standardGeneric("median"))

 and

 setMethod('median', signature(x='ANY'),
 function(x, ..., na.rm=FALSE){ x <- c(x, ...)
 return(stats::median(x, na.rm=na.rm)) } )

and

setMethod("median", signature(x='Raster'),
? ? ? ?function(x, ..., na.rm=FALSE){
})

etcetera,

but that gives an ugly message at startup about my package hiding
median from stats.

Is there a solution for this, or does the stats::median function need
to be changed?

Thanks, Robert

> # ? ? ? ? ? ? ? rasters <- list(...)
>



[Rd] generic method for median
Robert Hijmans