Is it possible to define a method for multiple classes (that are not
simply extensions of the other) without making separate setMethod()
calls?

As far as I understand it, this is how to currently set methods for
multiple classes:

setClass("myClass1", representation=representation(x="numeric",y="numeric"))
setClass("myClass2", representation=representation(x="numeric",z="character"))

setGeneric("x", function(object) standardGeneric("x"))

setMethod("x", signature("myClass1"), function(object) object@x)
setMethod("x", signature("myClass2"), function(object) object@x)


I was wondering if it is possible to do the equivalent of:

setMethod("x", signature(c("myClass1","myClass2")), function(object) object@x)

Or am I always required to do two separate setMethods?

Thanks,

-Robert

Robert M. Flight, Ph.D.
University of Louisville Bioinformatics Laboratory
University of Louisville
Louisville, KY

PH 502-852-1809 (HSC)
PH 502-852-0467 (Belknap)
EM robert.fli...@louisville.edu
EM rfligh...@gmail.com

Williams and Holland's Law:
       If enough data is collected, anything may be proven by
statistical methods.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to