I would like to create a function with methods with the same behavior for both numeric and logical arguments (using S4 methods) and different for matrix. I would typically do: setGeneric('foo',function(x) standardGeneric('foo')) setGeneric('foo','numeric',function(x) {...stuff 1...}) setGeneric('foo','logical',function(x) {...stuff 1...}) setGeneric('foo','matrix',function(x) {....stuff 2...}) If "stuff1" is identical for numeric and logical, can the two setGenerics be "combined" somehow? Thanks, Sean
Sean Davis wrote:> I would like to create a function with methods with the same behavior > for both numeric and logical arguments (using S4 methods) and different > for matrix. > > I would typically do: > > setGeneric('foo',function(x) standardGeneric('foo')) > setGeneric('foo','numeric',function(x) {...stuff 1...})Do you mean setMethod()?> setGeneric('foo','logical',function(x) {...stuff 1...}) > setGeneric('foo','matrix',function(x) {....stuff 2...}) > > If "stuff1" is identical for numeric and logical, can the two > setGenerics be "combined" somehow?Maybe using (implicit) inheritance? Uwe Ligges> > Thanks, > Sean > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html