title: Using spread with duplicate identifiers for rows
body: <p>I have a long form dataframe that have multiple entries for same date and person. </p>
  
  <pre><code>jj &lt;- data.frame(month=rep(1:3,4),
               student=rep(c("Amy", "Bob"), each=6),
               A=c(9, 7, 6, 8, 6, 9, 3, 2, 1, 5, 6, 5),
               B=c(6, 7, 8, 5, 6, 7, 5, 4, 6, 3, 1, 5))
  </code></pre>
  
  <p>I want to convert it to wide form and make it like this:</p>
  
  <pre><code>month Amy.A Bob.A Amy.B Bob.B
  1     
  2     
  3
  1
  2
  3
  1
  2
  3
  1
  2
  3
  </code></pre>
  
  <p>My question is very similar to <a href="https://stackoverflow.com/questions/30592094/r-spreading-multiple-columns-with-tidyr">this</a>. I have used the given code in the answer :</p>
  
  <pre><code>kk &lt;- jj %&gt;% 
    gather(variable, value, -(month:student)) %&gt;% 
    unite(temp, student, variable) %&gt;% 
    spread(temp, value)
  </code></pre>
  
  <p>but it gives following error:</p>
  
  <blockquote>
    <p>Error: Duplicate identifiers for rows (1, 4), (2, 5), (3, 6), (13, 16), (14, 17), (15, 18), (7, 10), (8, 11), (9, 12), (19, 22), (20, 23), (21, 24)</p>
  </blockquote>
  
  <p>Thanks in advance.
  Note: I don't want to delete multiple entries.</p>