+4 votes
in Programming Languages by (19.3k points)

The hist() function of R generates a histogram. Is there any way to find the count of each bin of the histogram?

1 Answer

0 votes
by (33.7k points)

The hist() function returns an object of class "histogram". It contains the component "counts". You can use it to see the count for each bin.

Here is an example:

> x=rnorm(50)
> h = hist(x, breaks = 5)
> h$counts
[1]  7 18 15  9  1

...