title: Convert R dataframe from long to wide format
body: <p>I have the following data:</p>
  
  <pre><code> df &lt;- data.frame(left=letters[1:4], right=replicate(1,sample(0:100,12,rep=TRUE)))
  </code></pre>
  
  <p>I looks like this (numbers might be different because on the random function)</p>
  
  <pre><code>   left  right
  1     a     6
  2     b    97
  3     c    78
  4     d    28
  5     a    61
  6     b    58
  7     c    56
  8     d    28
  9     a    90
  10    b    83
  11    c    72
  12    d    17
  </code></pre>
  
  <p>The first column is headers for a table, repeating 3 times. The new dataframe should look like this:</p>
  
  <pre><code>a  b  c  d
  6  97 78 28
  61 58 56 28
  90 83 72 17
  </code></pre>
  
  <p>When I use </p>
  
  <pre><code>spread(df,left, right)
  </code></pre>
  
  <p>it looks like this:</p>
  
  <pre><code>    a  b  c  d
  1   6 NA NA NA
  2  NA 97 NA NA
  3  NA NA 78 NA
  4  NA NA NA 28
  5  61 NA NA NA
  6  NA 58 NA NA
  7  NA NA 56 NA
  8  NA NA NA 28
  9  90 NA NA NA
  10 NA 83 NA NA
  11 NA NA 72 NA
  12 NA NA NA 17
  </code></pre>
  
  <p>Any idea?</p>