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=2,temp)

# OR I would like this to work:
temp=list(x3=3,x4=4,x5=5,x6=6,x7=7,x8=8,x9=9)
somefun(x1=1,x2=2,temp)

        [[alternative HTML version deleted]]

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to