richcalaway at revolution-computing.com
2009-Aug-31 23:20 UTC
[Rd] xy.coords assumes lists will have x and y components, but doesn't check (PR#13936)
Full_Name: Richard Calaway Version: 2.9.2 OS: Mac OS X 10.5.3 Submission from: (NULL) (65.47.30.18) Here's my sessionInfo():> sessionInfo()R version 2.9.2 (2009-08-24) i386-apple-darwin8.11.1 locale: en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base Currently, if you pass a list without x and y components to plot, you get an error from plot.window and some warnings about "no non-missing arguments" to max and min, and an empty graphics window:> x <- list(fred=rnorm(10), joe=runif(10)) > plot(x)Error in plot.window(...) : need finite 'xlim' values In addition: Warning messages: 1: In min(x) : no non-missing arguments to min; returning Inf 2: In max(x) : no non-missing arguments to max; returning -Inf 3: In min(x) : no non-missing arguments to min; returning Inf 4: In max(x) : no non-missing arguments to max; returning -Inf> traceback()4: plot.window(...) 3: localWindow(xlim, ylim, log, asp, ...) 2: plot.default(x) 1: plot(x) With the included patch, xy.coords returns an error and plot.window is never called:> plot(x)Error in xy.coords(x, y, xlabel, ylabel, log) : cannot find components 'x' and 'y' Index: xyz.coords.R ==================================================================--- xyz.coords.R (revision 49504) +++ xyz.coords.R (working copy) @@ -62,11 +62,15 @@ } } else if(is.list(x)) { - xlab <- paste(ylab, "$x", sep="") - ylab <- paste(ylab, "$y", sep="") - y <- x[["y"]] - x <- x[["x"]] - } + if (!is.null(x[["x"]]) && !is.null(x[["y"]])) { + xlab <- paste(ylab, "$x", sep="") + ylab <- paste(ylab, "$y", sep="") + y <- x[["y"]] + x <- x[["x"]] + } else { + stop("cannot find components 'x' and 'y'") + } + } else { if(is.factor(x)) x <- as.numeric(x) xlab <- "Index" @@ -155,14 +159,18 @@ } } else if(is.list(x)) { - zlab <- paste(xlab,"$z",sep="") - ylab <- paste(xlab,"$y",sep="") - xlab <- paste(xlab,"$x",sep="") - y <- x[["y"]] - z <- x[["z"]] - x <- x[["x"]] - } + if (!is.null(x[["x"]]) && !is.null(x[["y"]])) { + zlab <- paste(xlab,"$z",sep="") + ylab <- paste(xlab,"$y",sep="") + xlab <- paste(xlab,"$x",sep="") + y <- x[["y"]] + z <- x[["z"]] + x <- x[["x"]] + } else { + stop("cannot find components 'x' and 'y'") + } } + } ## Only x, y if(!is.null(y) && is.null(z)) {
Seemingly Similar Threads
- Vignette using parallel's makeCluster function has trouble building on Windows 7
- xy.coords
- scoping error in xy.coords (PR#932)
- Bug in xy.coords() or documentation error?
- Error in xy.coords(x, NULL, log = log) : (list) object cannot be coerced to type 'double'