Hi all, I am trying to find out how a certain functionality is implemented in R respectively what a certain found does exactly. Specifically I am interested in multivariate kernel density estimation. I found the "ks" package and its "kde" function. Usually, my preferred way to "look under the hood" of any function is to simply type the functions name without any brackets or arguments, in this case just: kde. And this works fine for kde itself. But kde calls other functions, such as kde.grid.3d or kde.points and typing those function names just yields "Error: Object '[function name]' not found". These functions aren't defined within kde either (as far as I can see). So here is my question: Am I doing something wrong? Is there a way to look up the code of these functions? (I already tried google but found only the usual documentation (vignettes) and articles referencing the function kde or the package ks). Thanks a lot in advance and kind regards RK
Probably these are non-exported functions. Try: getAnywhere(<function name>) Or if you know which package a function comes from: <package name>:::<function name> Best, Wolfgang -- Wolfgang Viechtbauer, Ph.D., Statistician Department of Psychiatry and Neuropsychology School for Mental Health and Neuroscience Faculty of Health, Medicine, and Life Sciences Maastricht University, P.O. Box 616 (VIJV1) 6200 MD Maastricht, The Netherlands +31 (43) 388-4170 | http://www.wvbauer.com> -----Original Message----- > From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Ronald > K?lpin > Sent: Wednesday, May 06, 2015 17:00 > To: r-help at r-project.org > Subject: [R] Looking up the code for a function > > Hi all, > > I am trying to find out how a certain functionality is implemented in R > respectively what a certain found does exactly. > > Specifically I am interested in multivariate kernel density estimation. > I found the "ks" package and its "kde" function. Usually, my preferred > way to "look under the hood" of any function is to simply type the > functions name without any brackets or arguments, in this case just: > kde. And this works fine for kde itself. But kde calls other functions, > such as kde.grid.3d or kde.points and typing those function names just > yields "Error: Object '[function name]' not found". These functions > aren't defined within kde either (as far as I can see). > > So here is my question: Am I doing something wrong? Is there a way to > look up the code of these functions? > > (I already tried google but found only the usual documentation > (vignettes) and articles referencing the function kde or the package ks). > > Thanks a lot in advance > and kind regards > > RK > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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.
Here's a discussion on stack overflow with more hints ... http://stackoverflow.com/questions/19226816/how-can-i-view-the-source-code-for-a-function ... and a link to an R-News article by Uwe Ligges on the topic http://cran.r-project.org/doc/Rnews/Rnews_2006-4.pdf (p. 43 f) Cheers, Boris On May 6, 2015, at 11:11 AM, Viechtbauer Wolfgang (STAT) <wolfgang.viechtbauer at maastrichtuniversity.nl> wrote:> Probably these are non-exported functions. Try: > > getAnywhere(<function name>) > > Or if you know which package a function comes from: > > <package name>:::<function name> > > Best, > Wolfgang > > -- > Wolfgang Viechtbauer, Ph.D., Statistician > Department of Psychiatry and Neuropsychology > School for Mental Health and Neuroscience > Faculty of Health, Medicine, and Life Sciences > Maastricht University, P.O. Box 616 (VIJV1) > 6200 MD Maastricht, The Netherlands > +31 (43) 388-4170 | http://www.wvbauer.com > >> -----Original Message----- >> From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Ronald >> K?lpin >> Sent: Wednesday, May 06, 2015 17:00 >> To: r-help at r-project.org >> Subject: [R] Looking up the code for a function >> >> Hi all, >> >> I am trying to find out how a certain functionality is implemented in R >> respectively what a certain found does exactly. >> >> Specifically I am interested in multivariate kernel density estimation. >> I found the "ks" package and its "kde" function. Usually, my preferred >> way to "look under the hood" of any function is to simply type the >> functions name without any brackets or arguments, in this case just: >> kde. And this works fine for kde itself. But kde calls other functions, >> such as kde.grid.3d or kde.points and typing those function names just >> yields "Error: Object '[function name]' not found". These functions >> aren't defined within kde either (as far as I can see). >> >> So here is my question: Am I doing something wrong? Is there a way to >> look up the code of these functions? >> >> (I already tried google but found only the usual documentation >> (vignettes) and articles referencing the function kde or the package ks). >> >> Thanks a lot in advance >> and kind regards >> >> RK >> >> ______________________________________________ >> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >> 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 -- To UNSUBSCRIBE and more, see > 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.