title: Flip order of data in grouped bar plot after coord_flip
body: <p>I've been having an annoying issue for which I haven't been able to find a specific solution. I'm trying to create a horizontal grouped bar plot; All I want is to take the standard vertical bar plot and rotate it 90 degrees to the right. When I use coord_flip, it rotates the plot to the right, but flips (reverses) the order of the data <em>within</em> each group. Here's an example:</p>
  
  <pre><code>library("ggplot2")
  
  df &lt;- data.frame(Group = c("A","A","A","B","B","B","C","C","C"),
                   Sub = c("1","2","3","1","2","3","1","2","3"),
                   Score = c(1,2,3,1,2,3,1,2,3))
  
  df$Group &lt;- factor(df$Group,
                         levels = c("A","B","C"),
                         labels = c("A","B","C"),
                         ordered = TRUE)
  
  df$Sub &lt;- factor(df$Sub,
                    levels = c("1","2","3"),
                    labels = c("1","2","3"),
                    ordered = TRUE)
  
  ggplot(data = df, aes(x = Group, y = Score, fill = Sub)) +
    geom_bar(stat="identity", position=position_dodge()) +
    coord_flip() +
    scale_x_discrete(limits = rev(levels(df$Group)))
  </code></pre>
  
  <p>I'm able to get the groups in the right order using:</p>
  
  <pre><code>scale_x_discrete(limits = rev(levels(df$Group)))
  </code></pre>
  
  <p>However, I can't get the order <em>within</em> each group correct. The legend and the data are opposite one another, and in this case, I want to change the order of the plotted data, and not the order of the legend.</p>
  
  <p>I've seen that you can fix the issue by setting the bar plot's position dodge to -.9, like this:</p>
  
  <pre><code>geom_bar(stat="identity", position=position_dodge(-.9))
  </code></pre>
  
  <p>Given that my grouping variables are strings, I'm not sure the solution proposed <a href="https://stackoverflow.com/questions/49448497/coord-flip-changes-ordering-of-bars-within-groups-in-grouped-bar-plot">here</a> would work.</p>
  
  <p>Any help would be greatly appreciated!</p>