[R] simple question on intervals

Ido M. Tamir tamir at imp.univie.ac.at
Wed Feb 14 16:55:31 CET 2007


>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



More information about the R-help mailing list