title: resample data based on a particular variable
body: <p>I have a large dataset as below. From the data, I want to randomly sample based on 'id'. Since the data has 5 ids, I would like to sample 5 ids with replacement and produce a new dataset with observations of sampled ids.  </p>
  
  <pre><code> id value   var1    var2    …
    1 1           
    1 2           
    1 3           
    1 4           
    2 5           
    2 6           
    2 7           
    3 8           
    3 9           
    3 10          
    4 11          
    4 12          
    4 13          
    5 14          
    5 15          
    5 16          
  </code></pre>
  
  <p>Let's suppose, I randomly draw 5 values from 1 to 5 (because there are 5 unique ids) and the result is (2 4 3 2 1). Then, I would like to have this data</p>
  
  <pre><code>  id    value   var1    var2    …
    2 5           
    2 6           
    2 7           
    4 11          
    4 12          
    4 13          
    3 8           
    3 9           
    3 10          
    2 5           
    2 6           
    2 7           
    1 1           
    1 2           
    1 3           
    1 4   
  </code></pre>