title: Randomly sample a percentage of rows within a data frame
body: <p>Related to <a href="https://stackoverflow.com/questions/9628152/random-sample-of-rows-from-subset-of-an-r-dataframe">this</a> question.</p>
  
  <pre><code>gender &lt;- c("F", "M", "M", "F", "F", "M", "F", "F")
  age    &lt;- c(23, 25, 27, 29, 31, 33, 35, 37)
  mydf &lt;- data.frame(gender, age) 
  
  mydf[ sample( which(mydf$gender=='F'), 3 ), ]
  </code></pre>
  
  <p>Instead of selecting a number of rows (3 in above case), how can I randomly select 20% of rows with "F"? So of the five rows with "F", how do I randomly sample 20% of those rows.</p>