title: $ operator is invalid for atomic vectors
body: <p>I have a very simple dataset and I tried to perform table() on the first column of the table, but R returns a captioned error message. I searched online but don't quite understand why this would even happen, as R accepts my table as a table... could anyone advise?</p>
  
  <p>My expect output:</p>
  
  <pre><code>&gt; table(tab$V1)
    CA 1
    CO 1
    OH 2
  </code></pre>
  
  <p>However it returns:</p>
  
  <pre><code>&gt; tabraw
    V1        V2
  1 OH Cleveland
  2 OH  Columbus
  3 CO    Denver
  4 CA   SanFran
  
  &gt; tab &lt;- table(tabraw)
  
  &gt; tab
      V2
  V1   Cleveland Columbus Denver SanFran
    CA         0        0      0       1
    CO         0        0      1       0
    OH         1        1      0       0
  
  &gt; table(tab$V1)
  Error in tab$V1 : $ operator is invalid for atomic vectors
  </code></pre>