[Rd] model.frame() call from inside a function (PR#3671)
Thomas Lumley
tlumley at u.washington.edu
Thu Aug 7 08:14:35 MEST 2003
On 7 Aug 2003, Peter Dalgaard BSA wrote:
> [[ I did discover yesterday (or maybe I was just reminded...) that we
> even have nonstandard nonstandard evaluation rules in some places
> (nls() seems to evaluate its model formula in the global environment
> even if it is given explicitly within a function:
>
> f <- function() {
> g <- function(a,x) exp(-a*x)
> nls(y~g(a,x),start=list(a=.1))
> }
> x <- 1:10
> y <- exp(-.12*x)+rnorm(10,sd=.001)
> f()
> Error in eval(expr, envir, enclos) : couldn't find function "g"
>
> Argh...]]
This is the same phenomenon that is documented for lattice graphics and
for lme in my notes on nonstandard evaluation rules. I think it *is* a
bug.
-thomas
More information about the R-devel
mailing list