On 09/06/2010 10:00 PM, Dario Strbenac wrote:> Hello,
>
> I've been attempting to make a generic method that dispatches on the
first argument, which can be either an S3 or an S4 class. This is as far as
I've gotten. Any suggestions about what to try next ?
>
> library(aroma.affymetrix)
> library(GenomicRanges)
>
> setGeneric("analyse", function(x, y, ...)
standardGeneric("analyse"))
>
> setMethodS3("analyse", "AffymetrixCelSet", function(x,
y, z, ...)
> {
> x;
> UseMethod("analyse")
> }
> )
>
> setGeneric("analyse")
>
> setMethod("analyse", "GRangesList", function(x, y, a,
b, c)
> {
> x;
> }
> )
I think (no testing on my end) you want
setOldClass("AffymetrixCelSet")
setGeneric("analyse", function(x, y, ...)
standardGeneric("analyse"))
setMethod(analyse, "AffymetrixCelSet", function(x, y, z, ...)
{
cat("AffymetrixCelSet\n")
x
})
setMethod(analyse, "GRangesList", function(x, y, a, b, c)
{
cat("GRangesList\n")
x
})
and then by way of reproducible example
> x = analyse(structure(list(), class="AffymetrixCelSet"))
AffymetrixCelSet> y = analyse(GRangesList())
GRangesList
Martin>
> Thanks,
> Dario.
>
> --------------------------------------
> Dario Strbenac
> Research Assistant
> Cancer Epigenetics
> Garvan Institute of Medical Research
> Darlinghurst NSW 2010
> Australia
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel