title: Frequency counts in R
body: <p>This may seem like a very basic R question, but I'd appreciate an answer. I have a data frame in the form of:</p>
  
  <pre><code>col1    col2
  a   g
  a   h
  a   g
  b   i
  b   g
  b   h
  c   i
  </code></pre>
  
  <p>I want to transform it into counts, so the outcome would be like this. I've tried using table () function, but seem to only be able to get the count for one column. </p>
  
  <pre><code>    a   b   c
  g   2   1   0
  h   1   1   0
  i   0   1   1
  </code></pre>
  
  <p>How do I do it in R? </p>