title: R: Recreate table from unique() and table()
body: <p>I have a dataframe with a column of about 300k records, of which 7k are unique.
  I need to perform heavy operations on the table, however the frequency of the records matters.<br>
  My idea is to perform the operations on the unique table and then to mulitply the result by the frequency of the repeated terms.</p>
  
  <pre><code>col&lt;-(c('a','f','d','s','a','d','s','a'))
  rep&lt;-data.frame(col)
  a&lt;-as.data.frame(table(rep))
  </code></pre>
  
  <p>Rep:  </p>
  
  <pre><code>  col
  1   a
  2   f
  3   d
  4   s
  5   a
  6   d
  7   s
  8   a
  </code></pre>
  
  <p>Freq. table:<br>
  <a href="https://i.stack.imgur.com/Zzg9D.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Zzg9D.png" alt="frequency table"></a></p>
  
  <p>Unique values:</p>
  
  <pre><code>1   a
  2   f
  3   d
  4   s
  </code></pre>
  
  <p>Is there any way to do this without a loop?</p>
  
  <p>The performance is next to terrible for this many rows... Do you have any sugestion for this?</p>
  
  <p>Thanks,<br>
  Miguel</p>