title: How to display the Values of a Column as the labels for the Bar in R
body: <p>Hi I'm struggling trying to plot a Bar Chart in R.</p>
  <p>I have a <strong>Factor</strong> with Categories and the Frequency for each category.<br />
  What I want to do is to display the Value of each category at the top of the bars, like when using:  <code>geom_text(aes(label = ..count..), stat = &quot;count&quot;, vjust = 1.5)</code> but cannot use this function because it is for when plotting data frames.</p>
  <blockquote>
  <p>In this case I want to plot a Vector with <em>BarChart()</em> or <em>barplot()</em> and display the Values above the bars.<br />
  A cool feature about BarChart() is that automatically displays the percentage values of the bars (%).</p>
  </blockquote>
  <p>The Vector is about the Average Hours of Sleep of 24 individuals.</p>
  <pre><code>#1. load lessR library
  library(lessR)
  
  #2. create a vector with range categories 
  sleep_hrs &lt;- cut(avg_sleep$AvgHrsAsleep, breaks = c(0,2,4,6,8,10,12))
  
  #3. use BarChart()
  BarChart(BarChart(sleep_hrs, main = &quot;Average Hours of Sleep by Ranges&quot;,
           xlab= &quot;Average Sleep Hours&quot;, ylab=&quot;Individuals&quot;)
  </code></pre>
  <p>The Vector looks like this:</p>
  <blockquote>
  <p>sleep_hrs<br />
  [0,2)   [2,4)   [4,6)   [6,8)  [8,10) [10,12)<br />
  2       1       5      13       2       1</p>
  </blockquote>
  <p>The graph looks like this:</p>
  <p><a href="https://i.stack.imgur.com/DvmKA.png" rel="nofollow noreferrer">BarChart</a></p>
  <p>Another way I have tried to figure out is, creating a Data Frame of the <em>sleep_hrs</em> Vector, and trying to display the 2nd column of Frequencies, and then display those frequencies above the bars. ie. for the range: 6-8, the frequency is 13, how could I display this 13 above the bar?<br />
  The data frame would look like this:</p>
  <pre><code>ranges  freq
  (0,2]   2  
  (2,4]   1  
  (4,6]   6  
  (6,8]   13  
  (8,10]  1  
  (10,12] 1  
  </code></pre>
  <p>This way I wouldn't need to use:<br />
  <code>geom_text(aes(label = ..count..), stat = &quot;count&quot;, vjust = 1.5)</code>, because I already have the count, and just want to display that value</p>
  <p>Any ideas or a different process would be appreciated.</p>