title: Create a barplot of two tables of differing length
body: <p>I can not seem to figure out how to get a nice  barplot that contains the data from two tables that contain a different number of columns.</p>
  
  <p>The tables in question are something like (snipped some data from the end):</p>
  
  <pre><code>&gt; tab1
     1    2    3    6    8   31
  5872 1525  831  521  299    4
  
  &gt; tab2
     1    2    3    4   22
  7874  422    2    5    1
  </code></pre>
  
  <p>Note the column names and sizes are different. When I just do <code>barplot()</code> on one of these tables it comes out with the plot I'd like (showing the column names as the X-axis, frequencies on Y-axis). But, I would like these two side by side.</p>
  
  <p>I've gotten as far as creating a data frame containing both variables as comments and the different row names in the first column (with <code>data.frame()</code>and <code>merge()</code>), but when I plot this the X-axis seems to be all wrong. Attempting to reorder the columns gives me an exception about lengths differing.</p>
  
  <p>Code:</p>
  
  <pre><code>combined &lt;- merge(data.frame(tab1), data.frame(tab2), by = c('Var1'), all=T)
  barplot(t(combined[,2:3]), names.arg = combined[,1], beside=T)
  </code></pre>
  
  <p>This shows a plot, but not all labels are present and the value for position 26 is plotted after 33.</p>
  
  <p>Is there any simple way to get this plot working? A ggplot2 solution would be nice.</p>