[R] Viewing function source

Barry Rowlingson B.Rowlingson at lancaster.ac.uk
Tue Aug 26 18:53:38 CEST 2003

Paul Meagher wrote:

> If I want to "view source" on the rpois() function, for example, can I do
> somethink like:
> source(rpois)
> To see how the function is implemented?

  You mean you've never typed 'ls' instead of 'ls()' and discovered this 
for yourself? I still do it all the time, and I've been using S/R for 
ten+ years :)

  Ah, maybe you're not a Unix person ('ls' is the command to list files).

  Just type a function name to see the source, or to see how it 
disappears into R's internal code. You can also do print(rpois), but 
you'll see for rpois it disappears into internal code:

function (n, lambda)
.Internal(rpois(n, lambda))
<environment: namespace:base>

  - now you need to get the full source code for R and look into C code.


More information about the R-help mailing list