Dear R colleagues,

I'm looking for some examples or vignettes or similar to suggest good ways to convert an expression to a function. In particular, I'd like to (semi-) automate the conversion of nls() expressions to residual functions. Example

Given variables y, T and parameters b1, b2, b3 in

exprtext<-"y~b1/(1+b2*exp(-b3*T))"

I'd like to generate a function

resids<-function(b, y, T){
        b1<-b[1]
        b2<-b[2]
        b3<-b[3] # Pedestrian but hopefully clear
        res<-b1/(1+b2*exp(-b3*T))-y
        return(res)
}

Preferably, I want to use only R facilities rather than call Perl or Python etc. And as much as possible, I'd like to automate the process. There are likely several ways to proceed.

Please contact me off list. I will report my success or lack thereof to the list in the near future.

Thanks,

John Nash

______________________________________________
R-help@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.

Reply via email to