[Rd] Same method for more than one class

Gregor Gorjanc gregor.gorjanc at bfro.uni-lj.si
Thu Mar 1 12:36:27 CET 2007


Sean Davis wrote:
...
> 
> Could you do:
> 
> catFun <- function(x) {
>   cat("Works")
> }
> setMethod(f="length", signature(x="myClass1"),def=catFun)
> setMethod(f="length", signature(x="myClass2"),def=catFun)

Yep, that is what I wanted.

setMethod(f="length", signature(x=c("myClass1", "myClass2"))

would be shorter, but your proposal is also OK.

Thank you again, Gregor



More information about the R-devel mailing list