title: tidyr::spread() with multiple keys and values
body: <p>I assume this has been asked multiple times but I couldn't find the proper words to find a workable solution.</p>
  
  <p>How can I <code>spread()</code> a data frame based on multiple keys for multiple values?</p>
  
  <p>A simplified (I have many more columns to spread, but on only two keys: <code>Id</code> and <code>time</code> point of a given measurement) data I'm working with looks like this:</p>
  
  <pre><code>df &lt;- data.frame(id = rep(seq(1:10),3), 
                   time = rep(1:3, each=10), 
                   x = rnorm(n=30), 
                   y = rnorm(n=30))
  
  &gt; head(df)
    id time           x           y
  1  1    1 -2.62671241  0.01669755
  2  2    1 -1.69862885  0.24992634
  3  3    1  1.01820778 -1.04754037
  4  4    1  0.97561596  0.35216040
  5  5    1  0.60367158 -0.78066767
  6  6    1 -0.03761868  1.08173157
  &gt; tail(df)
     id time           x          y
  25  5    3  0.03621258 -1.1134368
  26  6    3 -0.25900538  1.6009824
  27  7    3  0.13996626  0.1359013
  28  8    3 -0.60364935  1.5750232
  29  9    3  0.89618748  0.0294315
  30 10    3  0.14709567  0.5461084
  </code></pre>
  
  <p>What i'd like to have is a dataframe populated like this:</p>
  
  <p><a href="https://i.stack.imgur.com/tGtPw.png" rel="noreferrer"><img src="https://i.stack.imgur.com/tGtPw.png" alt="enter image description here"></a></p>
  
  <p>One row per <code>Id</code> columns for each value from the <code>time</code> and each measurement variable.</p>