[R] How to see a R function's code

Joshua Wiley jwiley.psych at gmail.com
Sat Feb 11 23:48:18 CET 2012


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/



More information about the R-help mailing list