R-alpha: image(): minor bug in R code and helpfile (fixes)

Ben Bolker ben@eno.Princeton.EDU
Sun, 15 Jun 1997 20:21:38 -0400 (EDT)

   I've noticed a few minor annoyances/mismatches with S in image().
  First, if you give it just a matrix argument (image(z)), it complains
rather than (as S does) using default x and y.

  This patch fixes it to work (mostly) like S (although in keeping with
what was in R already the default x,y coordinates are ((0,1),(0,1)) rather
than (1:nrow,1:ncol)). 

<        if(is.list(x)) {
<              z <- x$z
<              y <- x$y
<              x <- x$x
<               if(is.null(x) || is.null(y) || is.null(z))
<                stop("list must contain x, y, and z components with z a matrix")
<         }
<         else if(missing(y) && missing(z) && is.matrix(x)) {
<                 z <- x
<                 x <- seq(0,1,len=nrow(z))
<                 y <- seq(0,1,len=ncol(z))
<         }

  Second, the examples in the help file don't actually work(!) without the
following changes:

< image(z=volcano, x, y,
> image(volcano, x, y,
< contour(z=volcano, x, y, levels=seq(90, 200, by=5),
> contour(volcano, x, y, zc=seq(90, 200, by=5),

   (By the way, there is currently no help for contour().)

  A more general question: what are the ethics/legalities of adapting
S/S-PLUS function code to use in R?  

Benjamin Bolker          Dep't of Ecology and Evolutionary Biology,
ben@eno.princeton.edu    Princeton University
tel: (609) 258-6886,     fax: (609) 258-1334

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