title: Randomly select groups (and all cases per group) in R?
body: <p>I have an R dataframe with two levels of data: <code>id</code> and <code>year</code>. Within groups defined by <code>id</code>, the years increase (entire dataset has the same (number of) years per group, like so:</p>
  
  <pre><code>id    year    var1    var2
  11A   2001    ...     ...
  11A   2002    ...     ...
  11A   2003    ...     ...
  11A   2004    ...     ...
  13B   2001    ...     ...
  13B   2002    ...     ...
  13B   2003    ...     ...
  13B   2004    ...     ...
  22Z   2001    ...     ...
  </code></pre>
  
  <p>I have about 20.000 groups in my data, of couse way too many to make nice plots of growth curves. How do I randomly select about 20 of my id's? (so: also select all 4 rows of years corresponding to that id?)</p>