Skip to content

finding the code underneath a generic function

3 messages · Erin Hodgess, R. Michael Weylandt, David Winsemius

#
Dear R People:

How do you find the code underneath a generic function, please?

Sorry for the dumb question.

Thanks,
Sincerely,
Erin
#
A more detailed description is available in Circle 7 of the R Inferno
(among other places), but the short answer is you type methods(plot)
to see all the different plot functions and then just type the name of
the specific method to get the code. If you know which method you are
going for, you can usually call it directly: e.g., plot.ecdf

Michael
On Thu, Oct 13, 2011 at 9:26 PM, Erin Hodgess <erinm.hodgess at gmail.com> wrote:
#
On Oct 13, 2011, at 9:31 PM, R. Michael Weylandt wrote:

            
With the added strategy of using either getAnywhere() or the triple  
colon ":::" methods to get at S3 methods code that is not made  
visible. Notice that if you use:

methods(plot)
getAnywhere(plot.data.frame)

OR:
?plot.data.frame # to figure out which package name to use
graphics:::plot.data.frame

And then there are the S4 methods, but if you needed to ask this  
question, you may not be ready for S4 methods. Uwe Ligges wrote an  
artilc with atitle along ht elines of "Getting to the Sources" in the  
R-News a few years ago that is more complete. There it is, number 142:

http://cran.r-project.org/doc/Rnews/Rnews_2006-4.pdf