Hi I'm using "image" and got some strange results. When I define the color sequence as "col=gray(seq(0.95,0,-0.01))" or "col=gray(seq(0.94,0,-0.01))" I got an error Error in gray(level) : invalid gray level, must be in [0,1]. If I use 0.96 or 0.93 it works ... EJ ps: R 1.6.0 on SuSE Linux 8.0 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help 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-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Martin Maechler
2002-Oct-03 11:24 UTC
[R] seq(*,by=) rounding problem {was 'Strange behaviour of "image"'}
>>>>> "Ernesto" == Ernesto Jardim <ernesto at ipimar.pt> >>>>> on 03 Oct 2002 12:11:11 +0100 writes:Ernesto> Hi I'm using "image" and got some strange Ernesto> results. When I define the color sequence as Ernesto> "col=gray(seq(0.95,0,-0.01))" or Ernesto> "col=gray(seq(0.94,0,-0.01))" I got an error Ernesto> Error in gray(level) : invalid gray level, must be Ernesto> in [0,1]. Ernesto> If I use 0.96 or 0.93 it works ... yes, this is just floating point arithmetic, or "rounding" : The following reveals the problem : > range(seq(0.94,0, by = -0.01)) [1] -1.110223e-16 9.400000e-01 > range(seq(0.93,0, by = -0.01)) [1] 0.00 0.93 > range(seq(0.96,0, by = -0.01)) [1] 0.00 0.96 BTW, I usually never use "by=" in seq() exactly for this reason (and rather use "length=" instead). Martin -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help 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-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._