[R] Setting breaks to data more appropriately

David Winsemius dwinsemius at comcast.net
Mon Mar 22 20:45:48 CET 2010


On Mar 22, 2010, at 1:49 PM, LCOG1 wrote:

>
> Basic question.  For the below data, i would like to but each of the  
> values
> in a bin that represents their value.  So the below would hopefully  
> put .1
> in the 0-.1 bin, .2 in the .11-.2 bin and so forth.  The outlying  
> values
> would then be put into and outer category representing everything  
> >1.  Im
> using the breaks to inform some code for making a clorepleth map that
> represents probabilities, which in some cases IS greater than 1

... not if it's a quantile or a probability.

> and i need
> to identify those better.

Define "better".

> As my code stands now, my real data is put put
> into this form when brks is called:
>
>        0%        10%        20%        30%        40%         
> 50%        60%
> 0.00000000 0.05054675 0.07787235 0.11235238 0.14424786 0.18089360  
> 0.21475990
>       70%        80%        90%       100%
> 0.26309899 0.30807771 0.39478573 0.67573483.
>
> But what i want is for the values to be placed in bins corresponding  
> to
> their value(0-.1, .11-.2, .21-.3 etc)
>
> Pct.SFD<-c(.1,.2,.3,.4,.5,.6,.7,.8,.9,1,2,3)
> brks <- quantile(Pct.SFD, )
>
> I think this is clear.

It's not. You need to decide whether you want the breaking to be  
driven by you or by the data. If you are doing the driving then use

cut(object, breaks=c(seq(0,1, by=0.1), Inf) , right=TRUE)

If the data is doing the driving then:

cut(object, breaks=quantile(object, probs= seq(0,1,1/10 ) ) ,  
right=TRUE)

-- 
David.

> Thanks
> -- 
> View this message in context: http://n4.nabble.com/Setting-breaks-to-data-more-appropriately-tp1678019p1678019.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at 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.



More information about the R-help mailing list