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

Duncan Murdoch murdoch.duncan at gmail.com
Mon Feb 13 01:49:05 CET 2012


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



More information about the R-help mailing list