Skip to content
Prev 144772 / 398500 Next

How hist() decides breaks?

(Ted Harding) wrote:
No, it is not ignoring you.

Try

hist(rnorm(10000))
length(hist(rnorm(10000),breaks=50)$breaks)

and repeat a dozen of times or so. Chances are that you'll mostly see
lengths around 40, but definitely more than the 17 or so that you'll see
without the breaks=50. Next, try

diff(hist(rnorm(10000),breaks=50)$breaks)

and notice that this is usually 0.2, although if you repeat enough
times, you might get a couple of cases with 0.1 and a length of 75(-ish).

Get it? Otherwise look at help(pretty) since this is what is doing the work.

    -p