title: Multiple facets using ggplot2
body: <p>I have data like: </p>
  
  <pre><code>2L      A=&gt;C    6.2
  2L      A=&gt;G    13.6
  2L      A=&gt;T    6.7
  2L      C=&gt;A    5.3
  2L      C=&gt;G    3.8
  2L      C=&gt;T    12.6
  2L      G=&gt;A    14.1
  2L      G=&gt;C    4.3
  2L      G=&gt;T    5.5
  2L      T=&gt;A    10.3
  2L      T=&gt;C    12.6
  2L      T=&gt;G    5
  2R      A=&gt;C    5.1
  2R      A=&gt;G    11.2
  2R      A=&gt;T    9.4
  2R      C=&gt;A    4
  2R      C=&gt;G    4
  2R      C=&gt;T    11.6
  2R      G=&gt;A    17
  2R      G=&gt;C    4
  2R      G=&gt;T    6.9
  2R      T=&gt;A    9.1
  2R      T=&gt;C    12
  2R      T=&gt;G    5.8
  </code></pre>
  
  <p>And I'm trying to make separate bar plots for each chrom (<code>data[,1]</code>). I can plot it on the same plot:</p>
  
  <pre><code>library(ggplot2)
  
  snps&lt;-read.table("new.txt", header = FALSE)
  chroms&lt;-snps[,1]
  trans&lt;-snps[,2]
  freq&lt;-snps[,3]
  
  
  ggplot(snps, aes(x = trans, y = freq, group = chroms, fill = chroms)) + geom_bar(position="dodge",stat="identity")
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/jAB5B.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jAB5B.png" alt="enter image description here"></a></p>
  
  <p>However I would like to be able to plot each chrom separately. When i try to use <code>facet_grid</code> I get the following error message: </p>
  
  <pre><code>ggplot(snps, aes(x = trans, y = freq, group = chroms, fill = chroms)) + 
  geom_bar(position="dodge",stat="identity") + facet_grid(chroms ~ .)
  
  ---
  
  Error in combine_vars(data, params$plot_env, rows, drop = params$drop) : 
  At least one layer must contain all variables used for facetting
  </code></pre>
  
  <p>How can I correctly use facetting in this example?</p>