[R] finding the code underneath a generic function
David Winsemius
dwinsemius at comcast.net
Fri Oct 14 03:56:07 CEST 2011
On Oct 13, 2011, at 9:31 PM, R. Michael Weylandt wrote:
> 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
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
--
David.
>
> Michael
>
> On Thu, Oct 13, 2011 at 9:26 PM, Erin Hodgess
> <erinm.hodgess at gmail.com> wrote:
>> Dear R People:
>>
>> How do you find the code underneath a generic function, please?
>>
>> Sorry for the dumb question.
>>
>> Thanks,
>> Sincerely,
>> Erin
>>
>>
>> --
>> Erin Hodgess
>> Associate Professor
>> Department of Computer and Mathematical Sciences
>> University of Houston - Downtown
>> mailto: erinm.hodgess at gmail.com
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
David Winsemius, MD
West Hartford, CT
More information about the R-help
mailing list