[R] environments
Setzer.Woodrow@epamail.epa.gov
Setzer.Woodrow at epamail.epa.gov
Wed May 30 23:40:34 CEST 2001
I would like to be able, inside a function, to create a new function, and
use it as part of a formula as an argument to, say, gnls or nlme. for
example:
MyTop <- function(data=dta) {
Cexp <- function(dose,A,B,m){...}
Model <- as.formula(paste("y","~ Cexp(",paste(formals(Cexp),collapse
=", "),")"))
MyCall <- call("gnls",Model,dta,...)
eval(MyCall)
}
where "..." indicates I've left out unimportant details. In practice, the
function Cexp would be the result of some computations.
When I actually try this, I get an error return with the message "Cexp not
found". Is there a way around this? I know I can use "Cexp <<- ...", but
I'm trying to find a "clean" solution. Thanks.
R. Woodrow Setzer, Jr. Phone:
(919) 541-0128
Experimental Toxicology Division Fax: (919) 541-5394
Pharmacokinetics Branch
NHEERL MD-74; US EPA; RTP, NC 27711
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list