title: R: Reorder facet_wrapped x-axis with free_x in ggplot2
body: <p>I'm trying to use <code>reorder</code> in a facet-wrapped plot that also uses <code>scales = free_x</code> in ggplot2, but the reorder function isn't reordering the x-axis properly. Here's what I'm running:</p>
  
  <pre><code>library(ggplot2)
  
  df &lt;- read.table("speaking_distribution_by_play.txt",
                   header = F,
                   sep = "\t")
  
  ggplot(df, aes(x=reorder(V2, V3), y=V3)) + 
    geom_bar(stat = "identity") +
    facet_wrap(~V1, ncol = 4, scales = "free_x") + 
    opts(title = "Distribution of Speakers in Shakespearean Drama") + 
    xlab("Speaking Role") + 
    ylab("Words Spoken") +
    opts(axis.text.x=theme_text(angle=90, hjust=1))
  </code></pre>
  
  <p>Running that code on the data frame read from <a href="https://douglas-duhaime.squarespace.com/s/speaking_distribution_by_play.txt" rel="nofollow noreferrer">this tab-separated file</a> yields a plot in which the x-axis of each faceted plot is only partially ordered. <a href="https://stackoverflow.com/questions/13865133/reordering-geom-bar-when-using-facet-wrap">Someone else on SO</a> asked a very similar question, but the only proposed solution was to use grid arrange. Because my data set is quite a bit larger than the data set in that question, though, this won't be a terribly swift operation, so I wanted to ask: Is there a way to reorder the x axis of each faceted plot so as to show the bars in increasing (or decreasing) order of size? I would be very grateful for any help others can offer on this question.</p>