Skip to content

How to find where the source code of an R function or package is installed?

4 messages · Peng Yu, Charlie Sharpsteen, David Winsemius +1 more

#
I'm wondering where is the source of an R function or a package is.
For example, where is 'attributes'?
function (obj)  .Primitive("attributes")

I also do understand what .Primitive mean. Could somebody let me know
how to locate source file in an R installation? Why typing
'attributes' does not give its definition?
#
Peng Yu wrote:
A call to .Primitive() means that the function hands off execution to
internal code in the R environment.  This internal code is most likely in
the form of a compiled C or Fortran function.

To see what happens inside a .Primitive() call, you will have to start
digging into the R source code.  I think a good place to start may be to
download and unpack the R source and then look at:

  R-2.x.y/src/main/names.c

Which contains a table mapping .Primitive() and .Internal() calls to their
c-level counterparts.

Good luck!

-Charlie
#
On Nov 28, 2009, at 11:00 PM, Peng Yu wrote:

            
Looking below, it appears your understanding is different than mine.
Most R installations do not have the source code. But it is of course  
available.

https://svn.r-project.org/R/branches/R/src/main/
Because it's a .Primitive? ... which to me anyway means it is not  
implemented in R code.
David Winsemius, MD
Heritage Laboratories
West Hartford, CT
#
Check out:

Uwe Ligges. R Help Desk: Accessing the sources. R News, 6(4):43-45, October 2006
On Sat, Nov 28, 2009 at 11:00 PM, Peng Yu <pengyu.ut at gmail.com> wrote: