title: Creating a table of counts by some factor level in R
body: <p>I have some data of foods eaten on different days. </p>
  
  <pre><code>day &lt;- c(1,1,1,1,2,2,2,3,3,3,3,3)
  food &lt;- c('pizza','pizza','taco','snake','snake','taco','taco','pizza','taco','pizza','taco','snake')
  all &lt;- data.frame(day, food)
  </code></pre>
  
  <p>I'd like to create a table with food on the x axis, day on the y axis, and the number of foods per day in the matrices such that</p>
  
  <pre><code>food.list &lt;- unique(all$food)
   day.list &lt;- unique(all$day )
  output &lt;- data.frame(c(2,1,1),c(0,2,1),c(2,2,1))
  output
        1 2 3
  pizza 2 0 2
  taco  1 2 2
  snake 1 1 1
  </code></pre>
  
  <p>What is a straightforward way to solve this problem? </p>