title: How to get permutations by selecting one member of a subset with multiple subsets in R?
body: <p>Ok so in R, I want to determine the list of permutations without replacement of a list of variables, but for some of those variables I want to use only one item from each subset. So for example:</p>
  
  <pre><code>Set1: [a1, a2, a3]
  Set2: [b1, b2, b3]
  Set3: [c1, c2, c3]
  Set4: [d1, d2, d3]
  ...
  </code></pre>
  
  <p>And so I want to pick only one of the variables from each set (Set1 - Set 4+) and combine them with only one of the variables from the other sets. Giving results like:</p>
  
  <pre><code>results =
  
          Val1 Val2 Val3 Val4
  perm1:  a1   b3   c2   d1
  perm2:  a3   b1   c3   d2
  perm3:  a2   b2   c1   d3
  </code></pre>
  
  <p>So its a permutation where each slot (Val1, Val2 etc) has a subgroup of possibilities to pick from (Set1, Set2 etc). Does that make sense? </p>
  
  <p>I'm aware of several packages for normal permutations  and combinations (packages gtools, combinat, permutations, etc) but I am having trouble finding a package or function that would handle this sort of subgroup structure. Its important to note that I would not want multiple variable picks from the same set, just one pick per set (so just a1 or a3, not both, for each permutation). </p>