[R] Apply parameters to a function from a list

Greg Snow Greg.Snow at imail.org
Fri Feb 4 19:32:30 CET 2011


Try:

> do.call(test,point)

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
801.408.8111


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Florian Burkart
> Sent: Friday, February 04, 2011 7:36 AM
> To: r-help at r-project.org
> Subject: [R] Apply parameters to a function from a list
> 
> Hey,
> 
> this may be a simple question, but I am struggling to apply a list of
> parameters to a function.
> 
> 
> Say I have the following function:
> 
> test<-function(a=1,b=2,c=3,d=4){a+b+c+d}
> 
> And the following list:
> 
> point<-list(a=3,d=2)
> 
> Is there a way I can evaluate function test at point?
> 
> 
> 
> (Apart from changing function test to take in a list, and take values
> out of the list, but I'd rather not touch test).
> 
> Thanks vm
> 
> ______________________________________________
> R-help at r-project.org 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.



More information about the R-help mailing list