[R] Surprise when mapping matrix to image

Richard A. O'Keefe ok at cs.otago.ac.nz
Fri Aug 27 06:22:15 CEST 2004

Deepayan Sarkar <deepayan at cs.wisc.edu> wrote:
	I agree with you that the issues are related, but your (edited) quoting is

My quotes were selective but not otherwise edited.

	I interpret Prof Ripley's comment as implying that reading ?image
	would tell the user what happens when he calls image(x).

And that's how I interpreted it too.

	This is distinct from how to manipulate a matrix, which is what
	t(x)[ncol(x):1, ] is doing.  It doesn't seem obvious to me that this
	information should be in ?image,

Nobody whatsoever has suggested that the matrix manipulation code *SHOULD*
be in ?image.   Nobody.  Not me.  Not anyone else.  The original poster's
problem was not "how do I manipulate a matrix" but "why is the image the
wrong way around".

	and I still don't see how Prof Ripley's
	comment suggested that it was.

It didn't.  NOBODY has made any such suggestion.

	One can hardly expect all possible interactions to be documented.
Nobody has suggested that either.

All I was saying is this:
(1) The original poster's problem was a problem about image(),
    NOT a problem about matrix manipulation.
(2) We have no reason whatsoever to assert, hint, believe, or opine
    that the original poster was any less competent at matrix manipulation
    per se than anyone else reading this mail list.  He didn't have a
    matrix problem.
(3) The problem basically is precisely where Prof Ripley located it:
    a clash between
    (a) an extremely strong "cultural" expectation that the elements
        of a matrix will be presented with rows running from 1 at top
        to m at bottom and columns running from 1 at left to n at right, and
    (b) an extremely strong "cultural" expectation that the vertical
        axis of a plot runs from low at the bottom to high at the top, and
    (c) the fact that image() maps the "row" axis of a matrix to the
        horizontal axis of a plot and the "column" axis of a matrix to
        the vertical axis of a plot.
    Expectations (a) and (b) are not only part of general computing,
    they are strongly supported by R itself.  As for (c), it doesn't
    seem to me that it _had_ to be that way.
(4) Point (c) is a sufficiently strange quirk of image() that it is
    a stumbling block waiting to trip people up.  I've stumbled over
    it myself, which is how come I knew where to look in ?image.
    That makes it *essential* that it should be documented.
(5) And it *IS* documented.  It really is an image() problem, not a
    matrix problem, and the essential part of it *IS* documented.

Pointing out that a obvious nasty interaction *is* documented is
hardly a demand that all possible interactions should be documented.

How about this addition to the documentation?

    "The x axis corresponds to the rows of the matrix (first on the left
     to last on the right).  The y axis corresponds to the columns of the
     matrix (first at the bottom to last at the top)."

Once you know what image() is _intended_ to do with a matrix,
you can figure out the transposing and reversing you need for any
other view.  It's knowing you need to that's the problem.

More information about the R-help mailing list