User:Carl Boettiger/Notebook/Stochastic Population Dynamics/2010/08/16
|Stochastic Population Dynamics||Main project page|
Previous entry Next entry
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).