title: R - factor level orders (and ggplot group axis order)
body: <p>I am trying to control the order of discrete groups on an axis in ggplot, so I am setting the order of my factor variable.  Using the levels() function actually seems to change the data in the data frame - not the way R treats the underlying ordering of the data (see below). Am I doing something wrong? which function should I use instead of levels()?  thanks!</p>
  
  <pre><code>head(pctCStack,4)
  
         BRK          Time         x
  1      ICs December 2013 0.6717300
  2 Managers December 2013 0.8024344
  3      ICs     July 2014 2.0417851
  4 Managers     July 2014 1.3047233
  
  levels(pctCStack$BRK) &lt;- c("0-2 Years", "2-4 Years", "4+ Years", "ICs", "Managers")
  
  head(pctCStack,4)
          BRK          Time         x
  1 0-2 Years December 2013 0.6717300
  2 2-4 Years December 2013 0.8024344
  3 0-2 Years     July 2014 2.0417851
  4 2-4 Years     July 2014 1.3047233
  </code></pre>