[R] Evaluate a function for various value of parameters
rongguiwong
0034058 at fudan.edu.cn
Sat Oct 23 03:26:35 CEST 2004
Ãà 2004Ãê10ÃÃ23Ãà ÃÃÃÃÃù 06:10£¬Stephane DRAY ôµÃ£º
> Hello list,
>
> I have a problem ... and do not know how to solve it.
> I would like create a function that estimate the quality of the fit of
> different functions with different values of parameters.
> This problem is related to the following one:
> 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...
> mapply("*",1:10,5)
[1] 5 10 15 20 25 30 35 40 45 50
> outer(1:10,5,"*")
[,1]
[1,] 5
[2,] 10
[3,] 15
[4,] 20
[5,] 25
[6,] 30
[7,] 35
[8,] 40
[9,] 45
[10,] 50
is these meet your need?
try
>?outer
>?mapply
to see more details.
More information about the R-help
mailing list