On 02/18/2011 04:31 AM, Alaios wrote:
Dear all
when I call color.scale like this:
require('plotrix')
colcolor<-color.scale(c(range_sr,sr),extremes=c("red","blue"))
Error in if (min(reds)< 0 || max(reds)> 1) reds<- rescale(reds, c(0, :
missing value where TRUE/FALSE needed
range_sr
[1] -10.00000000000000 44.02977813958366
str(sr)
num [1:100, 1:100] 2.54 2.71 2.89 2.95 3.03 ...
this was working on simpler data sets before.
How can I understand more what was the problem in depth.? I have read the
source code of color.scale but unfortunately I did not make any progress to
understand this error message. Is it possible to raise an exception before the
error happens and see what went wrong?
Hi Alex,
When you concatenate (c) the extremes and the matrix, you get a vector:
> sr<-matrix(runif(10000,-10,44.03),100,100)
> str(sr)
num [1:100, 1:100] 11.2 27.13 4.13 -4.46 26.44 ...
> sr_colors<-color.scale(c(-10,44.03,sr))
> str(sr_colors)
chr [1:10002] "#000000" "#FFFFFF" "#646464" "#AFAFAF" "#434343" ...
Recreate the matrix:
sr_colors<-matrix(sr_colors[-(1:2)],100,100)
and all should be well.
Jim
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.