title: expand.grid for data.frame using dplyr full_join
body: <p>I am trying to get a function similar to <code>expand.grid</code> and works on <code>data.frame</code>.</p>
  
  <p>I found a solution in <a href="https://stackoverflow.com/questions/11693599/alternative-to-expand-grid-for-data-frames">Alternative to expand.grid for data.frames</a>
  that uses <code>merge</code> function to implement this.</p>
  
  <p>Since <code>merge</code> is quite slow compared to <code>dplyr</code> alternative <code>full_join</code>, so I try to use <code>full_join</code> to implement this function, but I couldn't get it done correctly. Here is an example I failed:</p>
  
  <pre><code>df &lt;- data.frame(attribute = paste0('attr', rep(1:5, each=2)),
                   value = paste0(rep(1:5, each=2), rep(c('A','B'), 2)),
                   score = runif(10))
  df
     attribute value      score
  1      attr1    1A 0.75600171
  2      attr1    1B 0.07086242
  3      attr2    2A 0.92403325
  4      attr2    2B 0.63414169
  5      attr3    3A 0.78763834
  6      attr3    3B 0.88576568
  7      attr4    4A 0.75998967
  8      attr4    4B 0.25205845
  9      attr5    5A 0.99304728
  10     attr5    5B 0.70389605
  </code></pre>
  
  <p>I tried to split <code>df</code> by <code>attribute</code> and join the list of score together:</p>
  
  <pre><code>dfList &lt;- df %&gt;%
    mutate(attribute=1) %&gt;%
    split(df$attribute)
  </code></pre>
  
  <p>And I "expand.grid" all these 5 tables together by:</p>
  
  <pre><code>Reduce(function(x, y) {full_join(x, y, by=c('attribute'='attribute'))}, dfList)
  </code></pre>
  
  <p>However, the result is weird:</p>
  
  <pre><code>   attribute value.x    score.x value.y   score.y value.x    score.x value.y   score.y value     score
  1          1      1A 0.75600171      2A 0.9240333      1A 0.75600171      2A 0.9240333    5A 0.9930473
  2          1      1A 0.75600171      2A 0.9240333      1A 0.75600171      2A 0.9240333    5B 0.7038961
  3          1      1A 0.75600171      2A 0.9240333      1A 0.75600171      2A 0.9240333    5A 0.9930473
  4          1      1A 0.75600171      2A 0.9240333      1A 0.75600171      2A 0.9240333    5B 0.7038961
  ...
  </code></pre>
  
  <p>The first 2 tables are shown twice, which is not desired. But when I try this on the first 4 tables it works perfectly:</p>
  
  <pre><code>Reduce(function(x, y) {full_join(x, y, by=c('attribute'='attribute'))}, dfList[1:4])
  
     attribute value.x    score.x value.y   score.y value.x   score.x value.y   score.y
  1          1      1A 0.75600171      2A 0.9240333      3A 0.7876383      4A 0.7599897
  2          1      1A 0.75600171      2A 0.9240333      3A 0.7876383      4B 0.2520584
  3          1      1A 0.75600171      2A 0.9240333      3B 0.8857657      4A 0.7599897
  4          1      1A 0.75600171      2A 0.9240333      3B 0.8857657      4B 0.2520584 
  ...
  </code></pre>
  
  <p>Where I did wrong?</p>
  
  <p>I'm using <code>dplyr</code> 0.4.3 with R version <code>3.2.4</code> on Ubuntu 14.04</p>