title: Factor order within faceted dotplot using ggplot2
body: <p>I'm trying to change the plotting order within facets of a faceted dotplot in ggplot2, but I can't get it to work. Here's my melted dataset:</p>
  
  <pre><code>&gt; London.melt
                        country medal.type count
  1                 South Korea       gold    13
  2                       Italy       gold     8 
  3                      France       gold    11
  4                   Australia       gold     7
  5                       Japan       gold     7
  6                     Germany       gold    11
  7  Great Britain &amp; N. Ireland       gold    29
  8          Russian Federation       gold    24
  9                       China       gold    38
  10              United States       gold    46
  11                South Korea     silver     8
  12                      Italy     silver     9
  13                     France     silver    11
  14                  Australia     silver    16
  15                      Japan     silver    14
  16                    Germany     silver    19
  17 Great Britain &amp; N. Ireland     silver    17
  18         Russian Federation     silver    26
  19                      China     silver    27
  20              United States     silver    29
  21                South Korea     bronze     7
  22                      Italy     bronze    11
  23                     France     bronze    12
  24                  Australia     bronze    12
  25                      Japan     bronze    17
  26                    Germany     bronze    14
  27 Great Britain &amp; N. Ireland     bronze    19
  28         Russian Federation     bronze    32
  29                      China     bronze    23
  30              United States     bronze    29
  </code></pre>
  
  <p>and here's my plot command:</p>
  
  <pre><code>qplot(x = count, y = country, data = London.melt, geom = "point", facets = medal.type ~.)
  </code></pre>
  
  <p>The result I get is as follows:</p>
  
  <p><img src="https://i.stack.imgur.com/bbVPW.png" alt="R plot"></p>
  
  <p>The facets themselves appear in the order I want in this plot. Within each facet, however, I'd like to sort by count. That is, for each type of medal, I'd like the country that won the greatest number of those medals on top, and so on. The procedure I have used successfully when there are no facets (say we're only looking at gold medals) is to use the  <code>reorder</code> function on the factor <code>country</code>, sorting by <code>count</code> but this doesn't work in the present example.</p>
  
  <p>I'd greatly appreciate any suggestions you might have. </p>