title: Repeat each row of data.frame the number of times specified in a column
body: <pre><code>df &lt;- data.frame(var1 = c('a', 'b', 'c'), var2 = c('d', 'e', 'f'),
                   freq = 1:3)
  </code></pre>
  
  <p>What is the simplest way to expand each row the first two columns of the data.frame above, so that each row is repeated the number of times specified in the column 'freq'?</p>
  
  <p>In other words, go from this:</p>
  
  <pre><code>df
    var1 var2 freq
  1    a    d    1
  2    b    e    2
  3    c    f    3
  </code></pre>
  
  <p>To this:</p>
  
  <pre><code>df.expanded
    var1 var2
  1    a    d
  2    b    e
  3    b    e
  4    c    f
  5    c    f
  6    c    f
  </code></pre>