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...
I would like that f could have a variable number of arguments. I have begin to write a function:
evaluatemyfunction=function(f,...){
b=match.call(expand.dot=F)$...
myg=expand.grid(lapply(b,eval)) #contains all combinations of parameters
for (i in 1:nrow(myg)){argsasname=paste(paste(names(myg),myg[1,],sep="="),collapse=",") # ?????? }
}
I have try to construct arguments of the function as character, then parse and pass it to f but parse doesn't work:
> parse(text=paste(paste(names(myg),myg[i,],sep="="),collapse=",")) Error in parse(file, n, text, prompt) : parse error
Any ideas ??
Thanks in advance,
sincerely
St�phane DRAY
--------------------------------------------------------------------------------------------------
D�partement des Sciences Biologiques Universit� de Montr�al, C.P. 6128, succursale centre-ville Montr�al, Qu�bec H3C 3J7, Canada
Tel : (514) 343-6111 poste 1233 Fax : (514) 343-2293
E-mail : [EMAIL PROTECTED]
--------------------------------------------------------------------------------------------------
Web http://www.steph280.freesurf.fr/
______________________________________________ [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
