title: Keep original column name order when using melt in R for variable number of columns
body: <p>Feel pretty dumb not figuring this out on my own, but figure I'll just ask at this point</p>
  
  <p>This is the data I'm using <code>www.google.org/flutrends/about/data/flu/us/data.txt</code> saved as a .csv in excel</p>
  
  <p>At the moment I have 162 columns using the data and I want to melt the data so I can group values to region names to create boxplots for all areas side by side. Unfortunately, melt orders the variable names alphabetically and I want to maintain the original column name order. I'm unsure how to do this. I imagine it has something to do with factor levels from what I've been able to find on the topic so far. This is the code I'm currently using, data1 is the read.csv:</p>
  
  <pre><code>data1 &lt;- read.csv('http://www.google.org/flutrends/about/data/flu/us/data.txt', skip = 10)
  gr_data1 &lt;- reshape2::melt(data1[-1]) #Group data for all US by area (variable) and flu trend (value)
  </code></pre>
  
  <p>I tried running this and then checking names(data1):</p>
  
  <pre><code>names(data1) &lt;- factor(names(data1), levels = unique(names(data1)))
  </code></pre>
  
  <p>But as you can see below didn't really solve anything for me in the order.
  This is what I'm running to make the plot:</p>
  
  <pre><code>library('ggplot2')
  ggplot(na.omit(gr_data1), aes(x = variable, y = value)) + geom_boxplot() + theme(axis.text.x = element_text(angle = 90, hjust = 1))
  </code></pre>
  
  <p>Ideally Baton Rouge LA would be last and United States first</p>
  
  <p>This is what the output looks like with the column ordered changed.
  <a href="https://i.stack.imgur.com/QMVvN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QMVvN.png" alt="enter image description here"></a></p>
  
  <p>This is what the data looks like. There's 162 columns including Date.</p>
  
  <p><a href="https://i.stack.imgur.com/FDYQc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FDYQc.png" alt="enter image description here"></a></p>
  
  <p>This is what the code does to the data -> i.stack.imgur.com/CWMbu.png</p>