On Tue, 26 Aug 2003, Paul Meagher wrote: > I know I should probably RTFM for this question, but could someone tell me > if R supports the idea of "viewing source" on any particular function you > want to use? > > 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?
It's even simpler in most cases, but you have picked an especially complicated example Just type the name of the function to see the R code > rpois function (n, lambda) .Internal(rpois(n, lambda)) But in this case it tells you that rpois is implemented in C code :( By convention, it is likely to be a function called do_rpois, however in this case we have an exception to the convention. You can look in src/main.names.c for the name of the C function. abacus% fgrep rpois names.c {"rpois", do_random1, 3, 11, 2, {PP_FUNCALL, PREC_FN,0}}, so the function do_random1 is actually involved. If you grep for that, you are directed to src/main/random.c and you will eventually find that the underlying code is in src/nmath/rpois.c and is commented with a reference to the ACM Transactions on Mathematical Software. -thomas ______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help