[R] Method dispatch in functions?

From: John McHenry <john_d_mchenry_at_yahoo.com>
Date: Thu, 28 Jun 2007 09:05:05 -0700 (PDT)


Hi,

Could someone point me in the right direction for documentation on the following question?

Let's say I have two objects a and b of classes A and B, respectively. Now let's say I write a function foo that does something similar to objects of type A and B. Basically I want to overload the function in C++ talk, so if I give foo and object of type A something (and this is my question) dispatches the call to, say, foo.A, and if I give foo and object of type B something dispatches the call to, say, foo.B.

I want to write foo.A and foo.B. How to I perform the method dispatch? From what I understand there are two ways in R: S3 and S4. What is the simple S3 way?

Thanks!

Jack.        


        [[alternative HTML version deleted]]



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 and provide commented, minimal, self-contained, reproducible code. Received on Thu 28 Jun 2007 - 16:36:53 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 01 Jul 2007 - 00:32:33 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.