Dear R users, I wonder if it is possible to form a function from a character string. Here is an example:
> x=3 > `-`(`+`(`^`(x,3),`^`(x,2)),1) # Here is my function evaluated. [1] 35 > V=list("`-`","(","`+`","(","`^`","(","x",",",3,")",",","`^`","(","x",",",2,")",")",",",1,")") > # Here I construct the string, it could be vector as well? > > S=noquote(paste(V,collapse="")) > > S [1] `-`(`+`(`^`(x,3),`^`(x,2)),1) # Here is the same as a character string. Now I'd like to create a function using this string, something like this, but of course, this doesn't work: S=as.expression(S) F1<-function(x){S} Is there some way to do this? Cheers, Atte Tenkanen University of Turku, Finland ______________________________________________ R-help@stat.math.ethz.ch 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.