[R] How to see how a function is written

Erik Iverson eriki at ccbr.umn.edu
Tue Jun 15 14:51:16 CEST 2010

Sergey Goriatchev wrote:
> Erik, I see the following when I type "apply" at the prompt:
>> apply
> standardGeneric for "apply" defined from package "base"
> function (X, MARGIN, FUN, ...)
> standardGeneric("apply")
> <environment: 0x03cad7d0>
> Methods may be defined for arguments: X, MARGIN, FUN
> Use  showMethods("apply")  for currently available ones.
> Also, whether I type "mean" at the prompt, or I type "edit(mean)", I
> do not see the underlying code for function "mean". How would I be
> able to see it?
> ---
> My machine:
> platform       i386-pc-mingw32
> arch           i386
> os             mingw32
> system         i386, mingw32
> status
> major          2
> minor          10.1
> year           2009
> month          12
> day            14
> svn rev        50720
> language       R
> version.string R version 2.10.1 (2009-12-14)

And what packages have you loaded?  That *is* your current definition of apply, 
I'm guessing some package is changing the base definition of 'apply', since 
that's not what happens in my R --vanilla session.  Regarding mean, you don't 
show your output, but my guess is that it *is* printing the function definition, 
which is generic.  Try typing out mean.default and see what happens.  What 
happens when you type lm ?

More information about the R-help mailing list