title: Barplot in R/ggplot with multiple factors
body: <p>I have a table which I would like to make into a plot using ggplot2 and I've been unsuccessful so far.
  I have prepared a simplified table that looks like this</p>
  
  <pre><code>df1&lt;-data.frame(Loc=c(rep("L1",5),rep("L2",3),rep("L3",4)),
  Type=c(rep("T1",3),rep("T2",2),"T1","T2","T2","T1","T1","T2","T2"),
         y2009=rep("A",12),y2010=c("A","B","A","A","A","A","B","B","A","A","B","B"),
         y2011=c("B","B","B","A","B",rep("B",4),"A","B","B"))
  df1
  </code></pre>
  
  <p>Loc has 3 locations.Each location has 2 types of samples T1 or T2. They start in 2009 as A and over time some becomes B. So, by 2011, there are lots of B.</p>
  
  <p>This is the figure I have so far</p>
  
  <pre><code>ggplot(df1,aes(x=Type)) + geom_bar()+facet_grid(~Loc)
  ggplot(df1,aes(x=y2009,fill=Type)) + geom_bar(position="dodge")+facet_grid(~Loc)
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/VFJBb.jpg" alt="enter image description here">
  <img src="https://i.stack.imgur.com/LCWyz.jpg" alt="enter image description here"></p>
  
  <p>I am not quite sure how to get counts from three factors.</p>
  
  <p>I would like a figure similar to below which I roughly drafted in paint. The facets are locations and I have made the bars only for Loc1 as example.
  <img src="https://i.stack.imgur.com/OrOzH.jpg" alt="enter image description here"></p>