title: Convert a long format to wide
body: <p>My data frame looks like this:</p>
  
  <pre><code> x &lt;- data.frame(c("a","a","a","a","b","b","c","c","c","a", "a"), c(1,2,3,4,1,2,1,2,3, 1, 2))
  names(x) &lt;- c("id","nr") 
  
        id      nr
     1   a       1
     2   a       2
     3   a       3
     4   a       4
     5   b       1
     6   b       2
     7   c       1
     8   c       2
     9   c       3
     10  a       1
     11  a       2
  </code></pre>
  
  <p>I want to have something like this:</p>
  
  <pre><code>  id   1  2  3  4
     a   1  2  3  4
     a   1  2  NA NA
     b   1  2  NA NA
     c   1  2  3  NA
  </code></pre>
  
  <p>I already used <code>dcast(x, id ~ nr, value.var ="nr")</code> but I got the warning: </p>
  
  <blockquote>
    <p>"Aggregation function missing: defaulting to length". </p>
  </blockquote>
  
  <p>I understand that this is due to non-unique rows. Also I created groups which give me the results above. But is there a way to create it without having to create groups?</p>
  
  <pre><code>x &lt;- data.frame(c("a","a","a","a","b","b","c","c","c","a", "a"), 
  c(1,1,1,1,1,1,1,1,1,2,2), c(1,2,3,4,1,2,1,2,3, 1, 2))
  names(x) &lt;- c("id", "group","nr")
  
  dcast(x, id + group ~ nr, value.var = "nr")
  </code></pre>