[Rd] eval() bug in plot.formula() ?
Peter Dalgaard BSA
p.dalgaard@biostat.ku.dk
10 Jan 2001 18:47:40 +0100
Martin Maechler <maechler@stat.math.ethz.ch> writes:
> I don't have time now to investigate myself,
> and I'm not feeling like deciding myself if the following is a bug:
>
> myplot <- function(dat, cex = 1.2, ...) {
> if(!is.data.frame(dat <- as.data.frame(dat)))
> stop("`dat' must be a data.frame")
> if(any(is.na(match(c("x","y"), names(dat)))))
> stop("`dat' must have a `x' and a `y' component")
> plot(y ~ x, data= dat, cex=cex, ...)
> }
>
> dd <- list(x= 1:12, y = sin((1:12)/10))
> myplot(dd)
> ## Error in eval(expr, envir, enclos) : ... used in an incorrect context
>
> myplot(dd, col = "red") ## Works fine
>
> myplot(dd, cex=1)
> ## Error in eval(expr, envir, enclos) : ... used in an incorrect context
>
> ------------
> The above code works fine in R 0.90 but fails already in 1.0.0
>
> I believe it *is* a bug
Hmm, it comes from fixing a much worse bug (the one where pch and
friends didn't get subsetted), so it's not advisable to revert the
change.
The problematic construction is this:
{
m <- match.call(expand.dots = FALSE)
if (is.matrix(eval(m$data, parent.frame())))
m$data <- as.data.frame(data)
dots <- m$"..."
dots <- lapply(dots, eval, data, parent.frame())
and the problem is that dots has ... as a component in some cases.
This looks more like a bug in match.call than in plot.formula, I think
--
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._