title: Using “combn” to create list of dataframes for all combinations of variables selected and columns for variables not selected
body: <p>From the <em>z</em> dataframe below I would like to generate a list of new dataframes in which each dataframe is based on a unique combination of 3 different values of Name vector. In the dataframe below I have 5 different names in the Name column (they have multiple replicate entries). The number of different combination of 3 is 10 (when sampled without replacement and order is not important).
  Though selection is based on the Name vector, I would like the new dataframes to include the other columns of information. In this case the Vote column.  I also would like that besides these two columns each dataframe contains two additional columns with the rows that were not selected. For example, if you run the code below the first dataframe in <em>combdf</em> will contain John, Lee, Susan and their votes. But I could not find/figure out how to add to that dataframe two columns for the remaining two names and their votes, and so forth for the rest of them. These two columns will have fewer rows so I am fine with NA for the missing cells.</p>
  <pre><code>Name &lt;- c(&quot;Jhon&quot;, &quot;Lee&quot;, &quot;Suzan&quot;, &quot;Abhinav&quot;,
        &quot;Brain&quot;)
  Vote &lt;- letters[1:21]
  z &lt;- as.data.frame (cbind(Name, Vote))
  comb&lt;-combn(unique(as.character(z$Name)), 3)
  combdf &lt;- apply(comb, 2, function(vec) z[ z$Name %in% vec, ] )
  </code></pre>