[R] Evaluate a function for various value of parameters

Gabor Grothendieck ggrothendieck at myway.com
Sat Oct 23 03:24:41 CEST 2004


Stephane DRAY <dray <at> biomserv.univ-lyon1.fr> writes:
: I would like to create a function "evaluatemyfunction" which evaluate a 
: function f for different values of parameters. For instance, if
: f=function(a,b) a*b
: evaluatemyfunction(f,1:10,5) would return:
: 5
: 10
: 15...
: 

This is not a general solution (Olaf has already provided that) but 
in some cases you may simply be able to write your function f so that 
it takes vector arguments.  For example, with the f you have above 
one could write f(1:10,5) .




More information about the R-help mailing list