Hi helpers,

I've been programming in R for a few months now but I still have doubts about my code - I would like it to be completely S4-compatible. The current code works fine but is probably 'unclean'.
I read the interesting article in the last R News and it helped me understand the difference on the whole between S3 and S4 classes, but I need a practical example. Could anyone point me out what's S3-like in the following sample and why it is not fully S4-compatible ? (any other comment welcome).


Thanks in advance.
Laurent

-------------------------------------------------------------------------------------------------

# I define a class
setClass("MyClass", representation(mynumber="numeric"));

# the initilization method
setMethod("initialize","MyClass",
         function(.Object)
         {
           [EMAIL PROTECTED] <- 10;
           return(.Object);
         }
);

# a function that objects of this class have
perform <- function(.Object) UseMethod("perform", .Object);

# the associated method
setMethod("perform","MyClass",
         function(.Object)
         {
           [EMAIL PROTECTED] <- [EMAIL PROTECTED] + 10;
           return(.Object);
          }
);

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help

Reply via email to