An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20120211/9723d250/attachment.pl>
How to see a R function's code
3 messages · Colstat, Joshua Wiley, Duncan Murdoch
Hi, Section 2 of the R Internals manual gives you some information. Assuming you have the source code, path_to_R/src/main/names.c holds the look up table. I am pretty sure that dt is one of the do_math* group (maybe math2??) so arithmetic.c may be useful. These are all text files so you can search in the source, but as these are pretty low level functions, I would expect it to take some time and effort to see and understand the code you want. Someone else on the list may know an easier way or know straight where to go for your particlar purpose. Cheers, Josh
On Sat, Feb 11, 2012 at 2:19 PM, Colstat <colstat at gmail.com> wrote:
I was wondering how do I actually see what's inside a function, say, density of t distribution, dt()? I know for some, I can type the function name inside R and the code will be displayed. ?But for dt(), I get
dt
function (x, df, ncp, log = FALSE)
{
? ?if (missing(ncp))
? ? ? ?.Internal(dt(x, df, log))
? ?else .Internal(dnt(x, df, ncp, log))
}
<environment: namespace:stats>
I am curious because I am doing rejection sampling and want to find a
"bigger" distribution.
? ? ? ?[[alternative HTML version deleted]]
______________________________________________ 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.
Joshua Wiley Ph.D. Student, Health Psychology Programmer Analyst II, Statistical Consulting Group University of California, Los Angeles https://joshuawiley.com/
1 day later
On 12-02-11 5:19 PM, Colstat wrote:
I was wondering how do I actually see what's inside a function, say, density of t distribution, dt()? I know for some, I can type the function name inside R and the code will be displayed. But for dt(), I get
dt
function (x, df, ncp, log = FALSE)
{
if (missing(ncp))
.Internal(dt(x, df, log))
else .Internal(dnt(x, df, ncp, log))
}
<environment: namespace:stats>
I am curious because I am doing rejection sampling and want to find a
"bigger" distribution.
See Uwe Ligges' article, "Accessing the sources", in http://cran.r-project.org/doc/Rnews/Rnews_2006-4.pdf This link and other good ones are in the "Technical papers" section on the HTML help page. Duncan Murdoch