Re: [R] Scoping bug!?

Kurt Hornik (Kurt.Hornik@ci.tuwien.ac.at)
Thu, 17 Dec 1998 18:41:41 +0100 (CET)

From: Kurt Hornik <Kurt.Hornik@ci.tuwien.ac.at>
Date: Thu, 17 Dec 1998 18:41:41 +0100 (CET)
To: Thomas Lumley <thomas@biostat.washington.edu>
Subject: Re: [R] Scoping bug!?
In-Reply-To: <Pine.GSO.4.03.9812170923000.4504-100000@wompom.biostat.washington.edu>
<Pine.GSO.4.03.9812170923000.4504-100000@wompom.biostat.washington.edu>

>>>>> Thomas Lumley writes:

> On Thu, 17 Dec 1998, Thomas Lumley wrote:
>> On Thu, 17 Dec 1998, Thomas Lumley wrote:
>>
>> > On Thu, 17 Dec 1998, Marcus Eger wrote:
>> >
>> > > Hello - any suggestions?!
>> > >
>> > > "fun" <- function (a1,a2,a3) {
>> > > ...
>> > > x<-rnorm(50)
>> > > a<-locfit(~x)
>> > > ...
>> > > }
>> > >
>> > > does not work, (Error: Object "x" not found) but
>> >
>> > Can we have more details: I get (current release version,
>> > sun-sparc-solaris2.6)
>> >
>>
>> Actually I do get the scoping bug. I had a variable called x in the global
>> environment before, which is why it worked.
>>

> Ok, the solution is to change the line
> frm <- eval(m, sys.parent())
> to
> frm <- eval(m, sys.frame(sys.parent()))

> about 10 lines down from the top of locfit().

Correct.
Actually, one may have to replace all occurrences of sys.parent() by
sys.frame(sys.parent()).

-k
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


This archive was generated by hypermail 1.02.