Select random sample by group, with additional condition in R
<p>Based on <a href="https://stackoverflow.com/questions/19989355/extracting-a-random-sample-of-rows-in-a-data-frame-with-a-nested-conditional">this post,</a> I'm trying to make a sample of rows. Using the same R iris data example. I've correctly create a sample of 15 rows for each species</p>

<pre><code>Selec_ir&lt;-iris[ with(iris, unlist(tapply(seq_len(nrow(iris)),
                          Species, FUN = sample, 15,replace=FALSE))), ]
</code></pre>

<p>But now how to create a sample based on the condition that the new selected row must be at least after 20 rows from the last selected one?</p>