+5 votes
in Programming Languages by (29.7k 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

+1 vote
by (51.1k 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


...