title: Generate a random, non-repeating subset of possible permutations in R
body: <p>Given <code>p</code> discrete variables, I would like to select randomly, <code>k</code> of their possible permutations. 
  In other words, for variables <code>a</code> in <code>{0,1}</code> and <code>b</code> in <code>{1,2,3}</code>, two random permutations would be 
  <code>[0,2]</code> and <code>[1,3]</code>.</p>
  
  <p>I would like to generate these without first generating a table of all possible permutations because to do that will become cumbersome as the number of variables and the values they can take increase. The catch is that I want to do this without getting repeats. The Code I found <a href="https://twitter.com/joshua_ulrich/statuses/243339556785618944" rel="nofollow">here</a> comes close:</p>
  
  <pre><code>x &lt;- sample.int (2, m*n, TRUE)-1L
  dim(x) &lt;- c(m,n) 
  </code></pre>
  
  <p>I realize that for <code>values &gt; 2</code>, I can reduce this to a matrix of binary values, so restricting to solving this problem for binary variables would be enough.</p>