[Rd] scale in stars() is not as documented (PR#1230)

maechler@stat.math.ethz.ch maechler@stat.math.ethz.ch
Mon, 31 Dec 2001 14:40:04 +0100 (MET)


>>>>> "BDR" == Brian D Ripley <ripley@stats.ox.ac.uk> writes:

    BDR> R 1.4.0 ?stars has

    BDR>    scale: logical flag: if `TRUE', the columns of the
    BDR> data matrix are scaled independently so that the
    BDR> maximum value in each column is 1 and the minimum is 0.
    BDR> If `FALSE', the presumption is that the data have been
    BDR> scaled by some other algorithm to the range [0,1].

    BDR> but the code has

    BDR>     if (scale) { x <- sweep(x, 2, apply(x, 2, max), FUN
    BDR> = "/") x[is.na(x)] <- 0 }

    BDR> and so just linearly (not affinely) scales the maximum
    BDR> to one. The result is very different star plots from
    BDR> the S original.  Try

    BDR> stars(state.x77[, c(7, 4, 6, 2, 5, 3)])

    BDR> compared to

    BDR> stars(state.x77[, c(7, 4, 6, 2, 5, 3)], byrow = T) # in S

    BDR> I suspect we should fix the code, but does anyone rely
    BDR> on it?



    BDR> BTW, it is hard to think of a more inefficient way to
    BDR> write that scaling!

Thank you, Brian, for fixing it (for R-patched i.e. R 1.4.1 to be).

Note that the scale thing all came from the original 

  ### T. Dye <tdye@lava.net>, July 1999
  ### This code started life as spatial star plots by David A. Andrews.
  ### See http://www.stat.rice.edu/~andrewsd/software/software.html.

(and that code was at least a start,..)
We had just done some (as you saw) `not quite perfect' NA handling.

Martin


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