title: Way to rearrange columns uniformly between multiple tables and plot?
body: <p>I have 3 DF's describing frequencies of certain tags by year. Each DF has the same column headings, except one is missing 1+ column because there is zero frequencies and 1 row because there is no frequency for that year.</p>
  <pre><code>df1 &lt;- data.frame(Year = c(&quot;2000&quot;, &quot;2001&quot;, &quot;2002&quot;, &quot;2003&quot;, &quot;2004&quot;),
               Country = c(1, 4, 5, 2, 26), 
               Flag = c(23, 2, 4, 2, 5),
               Anthem = c(3, 7, 8, 2, 3)
               )
  
  df2 &lt;- data.frame(Year = c(&quot;2000&quot;, &quot;2001&quot;, &quot;2002&quot;, &quot;2003&quot;, &quot;2004&quot;),
               Country = c(1, 4, 5, 2, 26), 
               Anthem = c(23, 2, 4, 2, 5),
               Flag = c(3, 7, 8, 2, 3)
               )
  
  df3missing &lt;- data.frame(Year = c(&quot;2001&quot;, &quot;2002&quot;, &quot;2003&quot;, &quot;2004&quot;),
               Anthem = c(4, 5, 2, 26), 
               Country = c(2, 4, 2, 5)
               )
  </code></pre>
  <p>If I were to plot them now, the colors would not represent the same column heading for each table because the order is different in the tables. And one table has a different number of columns and rows.</p>
  <pre><code>df11 &lt;- melt(df1, id.vars=&quot;Year&quot;)
  df22 &lt;- melt(df2, id.vars=&quot;Year&quot;)
  df3missing2 &lt;- melt(df3missing, id.vars=&quot;Year&quot;)
  
  
  ggplot(df11, aes(x = Year, y = value, fill = variable)) +
  geom_bar(position = &quot;fill&quot;, stat = &quot;identity&quot;)
  
  ggplot(df22, aes(x = Year, y = value, fill = variable)) +
  geom_bar(position = &quot;fill&quot;, stat = &quot;identity&quot;)
  
  ggplot(df3missing2, aes(x = Year, y = value, fill = variable)) +
  geom_bar(position = &quot;fill&quot;, stat = &quot;identity&quot;)
  </code></pre>
  <p>Is there a way to reorganize the tables so that all the columns are in the same order so that the same color across 3 plots corresponds to the same column for all tables? In my data, there are 10+ columns.</p>
  <p>TIA</p>