title: Shuffling a vector - all possible outcomes of sample()?
body: <p>I have a vector with five items.</p>
  
  <pre><code>my_vec &lt;- c("a","b","a","c","d")
  </code></pre>
  
  <p>If I want to re-arrange those values into a new vector (shuffle), I could use sample():</p>
  
  <pre><code>shuffled_vec &lt;- sample(my_vec)
  </code></pre>
  
  <p>Easy - but the sample() function only gives me one possible shuffle. <strong>What if I want to know <em>all</em> possible shuffling combinations?</strong> The various "combn" functions don't seem to help, and expand.grid() gives me every possible combination <em>with</em> replacement, when I need it <em>without</em> replacement.  What's the most efficient way to do this?</p>
  
  <p>Note that in my vector, I have the value "a" twice - therefore, in the set of shuffled vectors returned, they all should each have "a" twice in the set.</p>