>I have a number (correlation coefficient) "x" in [-1,1], and a color
>palette col<-grey(1:N/N) for a given N. I want to assign a color from "col"
>to "x" which corresponds to "x" in levels of cut(-1:1,N).
>
>So for N<-4 and x<-0.3, the color should be col[3]. For N<-4 and x<--0.8,
>the color should be col[1], etc.


findInterval(-0.3,seq(-1,1,2/4))

HTH
ido

______________________________________________
R-help@stat.math.ethz.ch 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.

Reply via email to