geom_text works for histogram in R?
<p>Wondering if <code>geom_text</code> works for <code>hist</code>? Tried following code and it seems no effect. I just want to show label (the number of elements belonging to a specific histogram bucket), when plotting each bar for each histogram bucket. Any solutions are appreciated. Thanks.</p>

<pre><code>p &lt;- hist(df$foo,
          main="title",xlab="foo")
p + geom_text()
</code></pre>

<p><strong>Edit 1</strong>, tried <code>geom_bar</code>, here is my code and it seems not working well, since I expect a number labelled on each bar. In the diagram, it only shows 2.5, 5, 7.5 and 10, I expect to show 1, 2, 3, ..., 9, 10 for each bar.</p>

<pre><code>g &lt;- ggplot(df, aes(df$foo))
g + geom_bar()
</code></pre>

<p><a href="https://i.stack.imgur.com/t6n46.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/t6n46.png" alt="enter image description here"></a></p>

<p>regards,
Lin</p>