Re: [R] How to pass a list of parameters into a function

2010-05-06 Thread Gene Leynes
I've written out an example of how to create a wrapper function to handle lengthy inputs in an automated way, just in case anyone searches for "how to pass arguments into a function as a list" and wants to see something that works start to finish. This can be especially helpful for use with functi

Re: [R] How to pass a list of parameters into a function

2010-04-19 Thread Barry Rowlingson
On Mon, Apr 19, 2010 at 5:58 PM, Gene Leynes wrote: > Does anyone know how to pass a list of parameters into a function? > > > for example: > > somefun=function(x1,x2,x3,x4,x5,x6,x7,x8,x9){ >    ans=x1+x2+x3+x4+x5+x6+x7+x8+x9 >    return(ans) > } > > somefun(1,2,3,4,5,6,7,8,9) > > # I would like t

Re: [R] How to pass a list of parameters into a function

2010-04-19 Thread Henrique Dallazuanna
Try this: do.call(somefun, c(x1 = 1, x2 = 2, as.list(temp))) On Mon, Apr 19, 2010 at 1:58 PM, Gene Leynes > wrote: > Does anyone know how to pass a list of parameters into a function? > > > for example: > > somefun=function(x1,x2,x3,x4,x5,x6,x7,x8,x9){ >ans=x1+x2+x3+x4+x5+x6+x7+x8+x9 >

[R] How to pass a list of parameters into a function

2010-04-19 Thread Gene Leynes
Does anyone know how to pass a list of parameters into a function? for example: somefun=function(x1,x2,x3,x4,x5,x6,x7,x8,x9){ ans=x1+x2+x3+x4+x5+x6+x7+x8+x9 return(ans) } somefun(1,2,3,4,5,6,7,8,9) # I would like this to work: temp=c(x3=3,x4=4,x5=5,x6=6,x7=7,x8=8,x9=9) somefun(x1=1,x2=