[R] [R-SIG-Finance] Method dispatch in functions?

Carlos J. Gil Bellosta cgb at datanalytics.com
Sun Jul 1 01:16:37 CEST 2007

Look at the UseMethod function. The help for the "print" method, a
heavily overloaded function, can also help.


Carlos J. Gil Bellosta

On Thu, 2007-06-28 at 09:05 -0700, John McHenry wrote:
> 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-SIG-Finance at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. 
> -- If you want to post, subscribe first.

More information about the R-help mailing list