From p.dalgaard@biostat.ku.dk  Fri May  4 17:06:23 2001
From: p.dalgaard@biostat.ku.dk (Peter Dalgaard BSA)
Date: 04 May 2001 18:06:23 +0200
Subject: [Rd] scoping error in xy.coords (PR#932)
In-Reply-To: Thomas Lumley's message of "Fri, 4 May 2001 08:40:48 -0700 (PDT)"
References: <Pine.A41.4.33.0105040829370.73704-100000@homer25.u.washington.edu>
Message-ID: <x2u231p08w.fsf@blueberry.kubism.ku.dk>

Thomas Lumley <tlumley@u.washington.edu> writes:

> evaluates to NULL, and x evaluates to y~x, rather than in the global
> environment where they would both evaluate to vectors.
> 
> In order to handle formulas correctly I think xy.coords needs to use the
> same sort of indirect evaluation as model.frame: eg
>    xy <-substitute(xy.coords(X,Y),list(X=substitute(x),Y=substitute(y)))
>    xy<-eval(xy,parent.frame())
> works as a replacement for the first two lines of lowess().  I hadn't
> realised that xy.coords() was supposed to handle formulas, and since it
> doesn't have a data= argument it can't do it very well.
> 
> This seems a bit drastic, given the number of times xy.coords is used.
> Perhaps there's a simpler solution.

Perhaps use the new formula environments in xy.coords? Seems to work


        if (inherits(x, "formula") && length(x) == 3) {
            ylab <- deparse(x[[2]])
            xlab <- deparse(x[[3]])
            y <- eval(x[[2]], environment(x), parent.frame())
            x <- eval(x[[3]], environment(x), parent.frame())
	}

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel 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-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


[Rd] scoping error in xy.coords (PR#932)
Peter Dalgaard BSA