[R] hist function to give each cell equal area

Achim Zeileis Achim.Zeileis at wu-wien.ac.at
Fri Jan 7 11:38:48 CET 2005


On Fri, 7 Jan 2005, Dan Bolser wrote:

>
> Hi,
>
> I want to use hist with non-equi-spaced breaks, picked such that the
> fraction of the data points falling in the cells (defined by 'breaks') is
> roughly equal accross all cells.
>
> Is there such a function that will automatically try to determine the
> breaks to fullfill this requirement?
>
> Something like..
>
> hist( x, br = magic_function_to_pick_breaks())

It's not that magic, but such points are usually called quantiles in
statistics...

> For example, if x looked like this...
>
> x <- c( 1:5, 10+1:5, 100+1:5 )
>
> the breaks would define cells like this
>
> hist(x,breaks=c(0,5,15,105))

quantile(x, 0:3/3, type = 1)

hth,
Z

> Is there such a function?
>
> ______________________________________________
> R-help at 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
>




More information about the R-help mailing list