Re: [Rd] loadings generic?

From: Martin Maechler <maechler_at_stat.math.ethz.ch>
Date: Mon 21 Mar 2005 - 17:49:00 GMT

>>>>> "PaulG" == Paul Gilbert <pgilbert@bank-banque-canada.ca>
>>>>> on Sun, 20 Mar 2005 10:37:29 -0500 writes:

    PaulG> Can loadings in stats be made generic?

It becomes a (S4) generic automagically when you define an S4 method for it. ;-)

{yes, I know this isn't the answer you wanted to hear;  but really, maybe it's worth considering to use S4 classes and  methods ?}

For S3, it's a bit uglier, but I think you could still do -- in your package --

if(!exists("loadings.default", mode="function")) {   loadings.default <- loadings
  loadings <- function(x, ...) UseMethod("loadings") }

loadings.<myclass> <- function(x, ...) {

   .........
}

and S3-export these.

Martin



R-devel@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Tue Mar 22 05:01:54 2005

This archive was generated by hypermail 2.1.8 : Mon 20 Feb 2006 - 03:21:02 GMT