[Rd] Bug in plot.formula (PR#757)

Prof Brian Ripley Prof Brian Ripley <ripley@stats.ox.ac.uk>
Mon, 4 Dec 2000 16:57:53 +0000 (GMT)


> From: presnell@stat.ufl.edu
> Date: Mon, 4 Dec 2000 17:29:56 +0100 (MET)
> To: r-devel@stat.math.ethz.ch
> Subject: [Rd] Bug in plot.formula (PR#757)
> CC: R-bugs@biostat.ku.dk
> X-Loop: R-bugs@biostat.ku.dk
> 
> 
> Here's a simple example:
> 
>   > x <- rnorm(20)
>   > y <- 1 + 10*x + rnorm(20)
>   > plot(y ~ x, subset=2*(1:10),xlab="In",ylab="Out")
>   Error in length(x) == l : comparison (1) is possible only for vector types
> 
> The problem seems to be in this section of the code for plot.formula:
> 
>   if (!missing(subset)) {
>     s <- eval(m$subset, data, parent.frame())
>     l <- nrow(data)
>     dosub <- function(x) if (length(x) == l) 
>       x[s]
>     else x
>     dots <- lapply(dots, dosub)
>   }
> 
> Sorry, no time this morning to attempt a fix myself, but I thought it
> best to get this in before 1.2 is released.

1.2 gives another error message, but the problem is using subset and
supplying a data argument.  Try

plot(y ~ x, subset=2*(1:10),xlab="In",ylab="Out", data=data.frame(x,y))

I *think* it should be l <- nrow(mf), but the function's author might
like to confirm the intention.

> 
> 
> Version:
>  platform = sparc-sun-solaris2.6
>  arch = sparc
>  os = solaris2.6
>  system = sparc, solaris2.6
>  status = 
>  major = 1
>  minor = 1.1
>  year = 2000
>  month = August
>  day = 15
>  language = R
> 
> Search Path:
>  .GlobalEnv, Autoloads, package:base
> 
> 
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> 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
> 
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

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