Randomly assign elements repeatedly to a limited number of groups
<p>There are N groups (aka judges, let's say 17), and M elements (let's call them cases, let's say 22) such that 3*M &lt;= 4*N.  </p>

<pre><code>N &lt;- LETTERS[1:17]
M &lt;- 1:22
</code></pre>

<p>I want to assign each of the N judges 4 or fewer cases, such that each case is evaluated by no more or no fewer than 3 judges, and no judge sees the same case twice. </p>

<pre><code>A : 1, 2, 19
B : 2, 3, 8, 22
...
Q : 1, 2, 12, 10
</code></pre>

<p>Any quick and easy way to do it in R?</p>

<p>Tried this so far:</p>

<pre><code>df &lt;- data.frame(ID=rep(M,3))
values &lt;- N
df$values[sample(1:nrow(df), nrow(df), FALSE)] &lt;- rep(values, 4)
</code></pre>