[R] color quantization / binning a variable into levels

From: David Forrest <drf5n_at_maplepark.com>
Date: Wed 22 Feb 2006 - 04:08:38 EST

Hi all,

I'd like to quantize a variable to map it into a limited set of integers for use with a colormap. "image" and filled.contour" do this mapping inside somewhere, but I'd like to choose the colors for plotting a set of polygons. Is there a pre-existing function that does something like this well? i.e., is capable of using 'breaks'?

quantize<-function(x,n=10, breaks=NULL){ # bin the variable x into n levels

x<- -10:10

quantize(x,breaks=c(5,7)) #

Thanks for your time,


 Dr. David Forrest
 drf@vims.edu                                    (804)684-7900w
 drf5n@maplepark.com                             (804)642-0662h

R-help@stat.math.ethz.ch mailing list
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Wed Feb 22 04:24:50 2006

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:42:38 EST