optimize will preserve attributes so try this: f <- function(x) structure(x^2, cubed = x^3) optimize(f, c(-1, 1))
On 6/9/06, paul sorenson <[EMAIL PROTECTED]> wrote: > I have a function (masheff) which returns a value which I can optimize > no problem, eg: > > optimize(masheff, c(15,30), maximum=TRUE, m_gd=5.13, v_tot=41, e_c=1.0) > > I would like masheff() to return multiple values say as a list with > named elements like so: > > v = masheff(...) > v$eff > v$extract > etc > > Is there a simple way to do this in an optimize context or would I need > to set some global variables and inspect them afterwards? > > ______________________________________________ > [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 > ______________________________________________ [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
