 <p>Assuming you want to simulate the order in which cases are picked, you can do this with a single call to <code>sample</code> (wrapped in <code>replicate</code> if you want to perform multiple simulations).</p> <p>For example:</p> <pre><code>set.seed(1) cases &lt;- 1:26 picks &lt;- sample(cases) picks ## [1] 7 10 14 21 5 19 23 13 12 2 4 3 25 22 24 6 8 9 16 11 26 17 15 1 18 20 </code></pre> <p>When no additional arguments are provided, <code>sample(x)</code> just permutes the vector <code>x</code>. Above, the case originally picked is case 7, and the remaining elements of <code>picks</code> represent the cases picked subsequently.</p> <p>To perform multiple simulations:</p> <pre><code>picks3 &lt;- replicate(3, sample(cases)) ## [,1] [,2] [,3] ## [1,] 1 12 21 ## [2,] 10 7 25 ## [3,] 21 2 11 ## [4,] 8 3 17 ## [5,] 11 25 9 ## [6,] 13 11 7 ## [7,] 25 14 16 ## [8,] 4 8 4 ## [9,] 15 17 13 ## [10,] 12 5 3 ## [11,] 24 19 19 ## [12,] 2 18 23 ## [13,] 22 10 20 ## [14,] 6 4 1 ## [15,] 20 6 8 ## [16,] 23 9 10 ## [17,] 14 1 12 ## [18,] 5 16 24 ## [19,] 9 23 14 ## [20,] 16 26 15 ## [21,] 26 21 5 ## [22,] 3 24 22 ## [23,] 17 15 26 ## [24,] 19 22 2 ## [25,] 7 13 18 ## [26,] 18 20 6 </code></pre> <p>Now, each column is an independent simulation of the pick order.</p> <hr> <p>For interest, to simulate one pick at a time with a <code>for</code> loop (e.g. if you want to insert other steps in the process), you could do something like the following (though there are many ways to do it):</p> <pre><code>picks &lt;- sample(cases, 1) # original pick for (i in 2:length(cases)) { # subsequent picks remaining &lt;- setdiff(cases, picks) picks[i] &lt;- remaining[sample(length(remaining), 1)] } </code></pre> <p>NB: we use <code>remaining[sample(length(remaining), 1)]</code> instead of just <code>sample(remaining, 1)</code> because at the last iteration, <code>remaining</code> will be a single number (the number of the last remaining case). Passing a single number, e.g. 4, to <code>sample</code> results in <code>sample(1:4, 1)</code> instead of the desired <code>sample(4, 1)</code>. See <a href="http://stackoverflow.com/q/13990125/489704">this post</a> for more on that.</p>