title: reorder character class data frame column and plot
body: <p>I have a data frame that looks like the following:</p>
  
  <pre><code>df &lt;- data.frame(date.time = c("Fri 00:00", "Fri 23:30", "Mon 00:00", "Mon 23:30", 
                                 "Sat 00:00", "Sat 23:30", "Sun 00:00", "Sun 23:30", 
                                 "Thu 00:00", "Thu 23:30", "Tue 00:00", "Tue 23:30", 
                                 "Wed 00:00", "Wed 23:30"), 
                   Price = c(36.15368, 41.61206, 30.80412, 37.47360, 38.04516, 35.72798, 
                             33.05613, 32.65447, 35.50335, 41.81241, 35.14006, 37.56432, 
                             35.04553, 38.00721))
  </code></pre>
  
  <p>the <code>date.time</code> values are of class character and the <code>Price</code> values are of class numeric.  I would like to plot the data using <code>ggplot</code>. The problem is that the data is in the wrong order.  I would like an order of: <code>sun, mon, ..., sat</code></p>
  
  <p>I have attempted to do this using the following code:</p>
  
  <pre><code>my.order &lt;- c(7,8,3,4,11,12,13,14,9,10,1,2,5,6)
  df %&gt;% 
    ggplot(aes(x = reorder(date.time, my.order), y = Price, group = 1)) + 
    geom_line()
  </code></pre>
  
  <p>but I end up getting a strange order that begins at the 'Tue' row of the original data frame. What am I doing wrong?</p>
  
  <p>i would also like to label the x axis and so i have tried the following code:</p>
  
  <pre><code>df %&gt;% 
    ggplot(aes(x = reorder(date.time, my.order), y = Price, group = 1)) + 
    geom_line() + 
    scale_x_discrete(name = 'Day', breaks = df$date.time[c(1,3,5,7,9,11,13)], 
                     labels = c("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"))
  </code></pre>
  
  <p>But the labels end up in the order of the original data set, while the plot is ordered beginning on 'Tue' as above. How can I get both the data and labels to appear in the order I would like?</p>
  
  <p>Edit:  I think it might have something to do with the levels.  Running the following code</p>
  
  <pre><code>df$date.time[c(7,8,3,4,11,12,13,14,9,10,1,2,5,6)]
  </code></pre>
  
  <p>results in the following output</p>
  
  <pre><code>[1] Sun 00:00 Sun 23:30 Mon 00:00 Mon 23:30 Tue 00:00 Tue 23:30 Wed 00:00 Wed 23:30
  [9] Thu 00:00 Thu 23:30 Fri 00:00 Fri 23:30 Sat 00:00 Sat 23:30
  14 Levels: Tue 00:00 Tue 23:30 Mon 00:00 Mon 23:30 Wed 00:00 Wed 23:30 ... Sun 23:30
  </code></pre>
  
  <p>Not sure why.</p>