[Rd] generic method for median

Robert Hijmans r.hijmans at gmail.com
Wed Mar 11 15:45:35 CET 2009


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(...)
>



More information about the R-devel mailing list