[R] Simple methods question

From: Sean Davis <sdavis2_at_mail.nih.gov>
Date: Thu 21 Apr 2005 - 22:38:48 EST

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?


R-help@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 Received on Thu Apr 21 22:51:42 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:31:21 EST