title: R - Counting elements in a vector
body: <p>is there a way to count elements in a vector, without considering its unique values?
  For example, I have a vector <code> vec &lt;- as.vector(c(&quot;A&quot;,&quot;A&quot;,&quot;B&quot;,&quot;B&quot;,&quot;A&quot;,&quot;A&quot;,&quot;B&quot;,&quot;B&quot;))</code>.
  I want to count the elements in the vector so it will return a vector of <code>[1] 2 2 2 2 </code>.</p>
  <p>I have tried using the <code>vec_count</code> function in the <code>vctrs</code> package:</p>
  <pre><code>my_vec &lt;- as.vector(c(&quot;A&quot;,&quot;A&quot;,&quot;B&quot;,&quot;B&quot;,&quot;A&quot;,&quot;A&quot;,&quot;B&quot;,&quot;B&quot;))
  my_count &lt;- vec_count(my_vec, sort = &quot;key&quot;)
  my_count$count
  [1] 4 4
  </code></pre>
  <p>But this function considers the unique elements in the vector, which is not what I want. Any ideas how to do this?</p>