zhijie zhang
2009-Jan-17 07:23 UTC
[R] Where to find the source codes for the internal function in stats package
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. [[alternative HTML version deleted]]
Felix Andrews
2009-Jan-17 08:38 UTC
[R] Where to find the source codes for the internal function in stats package
I guess you have the binary distribution, not the R source code. The functions you want seem to be defined in the files dchisq.c and dnchisq.c in https://svn.r-project.org/R/trunk/src/nmath/ 2009/1/17 zhijie zhang <rusers.sh at gmail.com>:> 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. > > [[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. >-- Felix Andrews / ??? http://www.neurofractal.org/felix/ 3358 543D AAC6 22C2 D336 80D9 360B 72DD 3E4C F5D8
Duncan Murdoch
2009-Jan-17 11:00 UTC
[R] Where to find the source codes for the internal function in stats package
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
Murray Cooper
2009-Jan-17 22:40 UTC
[R] Where to find the source codes for the internal function in stats package
Dear Dr Murdoch,
I understand in principle your explanation, but specifically where in the
source distribution are these functions found? For instance, I would like
to look at the code for model.matrix. Ex:
ans <- .Internal(model.matrix(t, data))
I have looked at the source distribution but been unable to locate the
file which contains model.matrix.
Thanks for your help.
Murray Cooper
----- Original Message -----
From: "Duncan Murdoch" <murdoch at stats.uwo.ca>
To: "zhijie zhang" <rusers.sh at gmail.com>
Cc: <r-help at stat.math.ethz.ch>
Sent: Saturday, January 17, 2009 6:00 AM
Subject: Re: [R] Where to find the source codes for the internal function in
stats package
> 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
>
> ______________________________________________
> 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.
>
Gabor Grothendieck
2009-Jan-17 22:57 UTC
[R] Where to find the source codes for the internal function in stats package
Look for do_modelmatrix here: https://svn.r-project.org/R/trunk/src/main/model.c On Sat, Jan 17, 2009 at 5:40 PM, Murray Cooper <myrmail at earthlink.net> wrote:> Dear Dr Murdoch, > > I understand in principle your explanation, but specifically where in the > source distribution are these functions found? For instance, I would like > to look at the code for model.matrix. Ex: > ans <- .Internal(model.matrix(t, data)) > > I have looked at the source distribution but been unable to locate the > file which contains model.matrix. > > Thanks for your help. > > Murray Cooper > > ----- Original Message ----- From: "Duncan Murdoch" <murdoch at stats.uwo.ca> > To: "zhijie zhang" <rusers.sh at gmail.com> > Cc: <r-help at stat.math.ethz.ch> > Sent: Saturday, January 17, 2009 6:00 AM > Subject: Re: [R] Where to find the source codes for the internal function in > stats package > > >> 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 >> >> ______________________________________________ >> 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. >