From saikat at stat.wisc.edu  Thu Aug  7 12:08:31 2003
From: saikat at stat.wisc.edu (Saikat DebRoy)
Date: Thu Aug  7 17:08:11 2003
Subject: [Rd] model.frame() call from inside a function (PR#3671)
In-Reply-To: <Pine.A41.4.44.0308070713060.77846-100000@homer22.u.washington.edu>
Message-ID: <01E63B3C-C8E9-11D7-AF59-0003931A3C9E@stat.wisc.edu>

On Thursday, Aug 7, 2003, at 10:14 US/Eastern, Thomas Lumley wrote:

> 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.

I think this was fixed in lattice a few months ago - from the 
ChangeLog, on March 3rd.


[Rd] model.frame() call from inside a function (PR#3671)
Saikat DebRoy