I\'m trying to write a function to do a particular job (in my case, analyse a data set for outliers) so the first things I want to do is look at how other people have done s
When you say
the function did do other things depending on the class of the object thrown at it
you are already at the heart of the S3 dispatch mechanism! So I would recommend reading a programming book on R as e.g.
or other resources from this SO question on R books along with an example package or two from the rich set of CRAN packages.