[R] Creating functions of "many" arguments

Erik Iverson eriki at ccbr.umn.edu
Fri Jul 16 03:40:10 CEST 2010


On 07/15/2010 08:32 PM, Axel Urbiz wrote:
> Dear users,
>
> My apologies for the simple question. I'd like to create a function where
> the number of arguments is as big as the size of my data set. Supose I have
> n observations in my data, how can I write a function like
>
> fun<- function (x1,x2,....,xn)  {x1*x2*.......*xn}

You take the 'whole object' approach.

x <- 1:10

sum(x)

for example.  You'll have to be more specific with what you want your function 
to do, since there are many ways to do this sort of thing.



More information about the R-help mailing list