On Tue, 21 Feb 2006 11:08:38 -0600 (CST), David Forrest wrote: perhaps "binning" of package "sm" is what you want
best wishes, Adelchi Azzalini DF> Hi all, DF> DF> I'd like to quantize a variable to map it into a limited set of DF> integers for use with a colormap. "image" and filled.contour" do DF> this mapping inside somewhere, but I'd like to choose the colors DF> for plotting a set of polygons. Is there a pre-existing function DF> that does something like this well? i.e., is capable of using DF> 'breaks'? DF> DF> quantize<-function(x,n=10, breaks=NULL){ DF> # bin the variable x into n levels DF> xmin<-min(x) DF> xmax<-max(x) DF> 1+floor(n*(x-xmin)/(xmax-xmin)*.999) DF> } DF> DF> x<- -10:10 DF> cbind(x,quantize(x,2),quantize(x),quantize(x,21)) DF> DF> quantize(x,breaks=c(5,7)) # DF> DF> Thanks for your time, DF> DF> Dave -- Adelchi Azzalini <[EMAIL PROTECTED]> Dipart.Scienze Statistiche, Università di Padova, Italia tel. +39 049 8274147, http://azzalini.stat.unipd.it/ ______________________________________________ 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