title: How to create independent samples of equal size?
body: <p>Here is how I currently create two independent samples, DS and RS:</p>
  
  <pre><code>data$rnd&lt;-runif(nrow(data),0,1)
  fraction&lt;-0.5
  DS&lt;-subset(data, rnd &lt;= fraction) 
  RS&lt;-subset(data, rnd &gt; fraction) 
  </code></pre>
  
  <p>obviously, this will only give me two samples of roughly equal size. I guess my cross-validation analysis would be more efficient if I could get exactly equal splits (however my sample has unequal n). I thought about a natural number generator that picks each number between 1 and N exactly once but I didn't find anything.</p>