title: Reshape dataframe so that each entry of column in repeated over all other columns
body: <p>I have a data.frame, dat, which looks like this</p>
  
  <pre class="lang-r prettyprint-override"><code>dat = data.frame(x = c(1, 1.1, 1.2, 1.3), y = c(2, 2.1, 2.2, 2.3), output = c(2, 10, 101, 100))
  </code></pre>
  
  <pre class="lang-r prettyprint-override"><code>    x   y output
  1 1.0 2.0      2
  2 1.1 2.1     10
  3 1.2 2.2    101
  4 1.3 2.3    100
  </code></pre>
  
  <p>I want that each pair of elements of columns "x" and "output" is repeated over column "y".</p>
  
  <p>I have tried using <code>tidyr::spread</code>, <code>tidyr::gather</code>, and <code>reshape2::melt</code> to no avail. This is because I am a beginner in using <code>tidyr</code> and <code>reshape2</code> and other reshaping packages. </p>
  
  <p>Currently, I have resorted to using a loop to extract each element pair from columns "x" and "output" and creating a new data.frame, <code>final_df</code>, that combines the resulting data.frames. I believe this is definitely not the most efficient way to do it and am confident that there is a one-liner function somewhere which can do this magic for me.</p>
  
  <p>In the resulting data.frame, if I subset the data.frame using say,</p>
  
  <pre><code>dplyr::filter(final_df, x == 1, output == 2)
  </code></pre>
  
  <p>it should look like so:</p>
  
  <pre class="lang-r prettyprint-override"><code>data.frame(x = rep(1, dat$x[1], nrow(dat)), y = dat$y, output = rep(dat$output[1], nrow(dat)))
  </code></pre>
  
  <pre class="lang-r prettyprint-override"><code>  x   y output
  1 1 2.0      2
  2 1 2.1      2
  3 1 2.2      2
  4 1 2.3      2
  </code></pre>
  
  <p>I will be happy with an answer using tidyverse. Thank you.</p>