User:Carl Boettiger/Notebook/Stochastic Population Dynamics/2010/08/16
|Stochastic Population Dynamics||<html><img src="/images/9/94/Report.png" border="0" /></html> Main project page|
<html><img src="/images/c/c3/Resultset_previous.png" border="0" /></html>Previous entry<html> </html>Next entry<html><img src="/images/5/5c/Resultset_next.png" border="0" /></html>
Duncan pts out: the S3 mechanism is
custom = function(x, y, ...) UseMethod("custom")
Then that will find and use custom.foo, etc. based on the class of the value of x. You can have it dispatch on a different parameter, but that is not very common. And to dispatch on the types/classes of multiple parameters, e.g. x is a numeric vector, y is a matrix, you would need to use S4.
See the setGeneric() function in R for S4 method (also compatible with S3 classes).