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

Sharpie chuck at sharpsteen.net
Sun Nov 29 05:44:30 CET 2009



Peng Yu wrote:
> 
> I'm wondering where is the source of an R function or a package is.
> For example, where is 'attributes'?
> 
>> 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?
> 
> 

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
-- 
View this message in context: http://n4.nabble.com/How-to-find-where-the-source-code-of-an-R-function-or-package-is-installed-tp930625p930631.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list