title: How to group in ggplot geom_bar R
body: <p>I am failing miserably trying to get my head around grouping in ggplot geom_bar. </p>
  
  <p>I have a mock data frame structure, although the real data frame is significantly larger:</p>
  
  <pre><code>df&lt;-data.frame(id=1:12,
      count=c(12,5,33,6,43,12,8,56,14,43,36,32),
      name=c("A","A","A","B","B","B","B","B","B","C","C","D"),
      stringsAsFactors=F)
  </code></pre>
  
  <p>using either the mock or in this case the real data frame, I get a plot like</p>
  
  <pre><code>ggplot(df, aes(x=id,y=count)) + geom_bar(stat="identity")
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/Jujzk.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Jujzk.jpg" alt="enter image description here"></a></p>
  
  <p>This plots everything in the correct order (as laid out in the data frame), however, along the x-axis, rather than the numeric <em>id</em> values, I would like to use the <em>name</em> as a group: "A" for the first three values, "B" six, "C" for the next two and "D" for the final value - or the proper names in the case of the full dataset.  </p>
  
  <p>I have a feeling this should be quite easy providing my dataframe is formatted is correct. Any help, much appreciated. </p>