[R] Where to find the source codes for the internal function in stats package

Duncan Murdoch murdoch at stats.uwo.ca
Sat Jan 17 12:00:13 CET 2009


On 17/01/2009 2:23 AM, zhijie zhang wrote:
> Dear all,
>   I want to see the source codes for "dchisq(x, df, ncp=0, log = FALSE)",
> but cannot find it.
> I input "dchisq" in the R interface, and then enter, the following message
> return:
>> dchisq
> /*****************************************************/
> function (x, df, ncp = 0, log = FALSE)
> {
>     if (missing(ncp))
>         .Internal(dchisq(x, df, log))
>     else .Internal(dnchisq(x, df, ncp, log))
> }
> <environment: namespace:stats>
> /*****************************************************/
>  It seems that dchisq() is the internal function in STATS package. So go
> to "C:\Program Files\R\R-2.7.2\library\stats" to look for it. I browsed the
> files in this catalog, but it seems that i missed it.
> Anybody can tell me how and where to find the codes, Thanks a lot.

Uwe Ligges wrote a nice article on finding source in R News :

   Ligges, U. (2006): R Help Desk: Accessing the Sources. R News 6 (4), 
43-45. http://cran.r-project.org/doc/Rnews/

As it explains, .Internal() calls functions in the main R binary, not in 
a package DLL.

Duncan Murdoch




More information about the R-help mailing list