[R] Passing values to a function when using apply
Erik Iverson
eriki at ccbr.umn.edu
Tue Apr 27 21:34:51 CEST 2010
Abhishek Pratap wrote:
> Hi Guys
>
> Thank you for clearing something I dint know. Just wondering the
> reason of putting the word function(x) in the apply function when we
> have already declared stats function separately.
>
> I better understand how the arguments are passed.
>
> Thanks!
> -Abhi
>
That's creating a *new* function, one without a name, that basically
"breaks up" the x argument into two values, and passes those along with
the third argument and passes these to your stats function. You either
have to write stats to accept two arguments, or leave stats accepting
three arguments and use this method.
More information about the R-help
mailing list