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

Saikat DebRoy saikat at stat.wisc.edu
Thu Aug 7 12:08:31 MEST 2003


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.



More information about the R-devel mailing list