title: ggplot2: add line for average per group
body: <pre><code>library(ggplot2)
  
  orderX &lt;- c("A" = 1, "B" = 2, "C" = 3)
  y &lt;- rnorm(20)
  x &lt;- as.character(1:20)
  group &lt;- c(rep("A", 5), rep("B", 7), rep("C", 5), rep("A", 3))
  df &lt;- data.frame(x, y, group)
  df$lvls &lt;- as.numeric(orderX[df$group])
  
  ggplot(data = df, aes(x=reorder(df$x, df$lvls), y=y)) + 
  geom_point(aes(colour = group)) + 
  geom_line(stat = "hline", yintercept = "mean", aes(colour = group))
  </code></pre>
  
  <p>I want to create a graph like this:
  <img src="https://i.stack.imgur.com/e20c9.png" alt="graph with averages for each group"></p>
  
  <p>This does work, when I do not need to reorder the values of X, however, when I do use reorder, it doesn't work anymore.</p>