title: Is there a way in R to cast various items within a group to many columns?
body: <p>Say I have a data frame like this:</p>
  
  <pre><code> df&lt;-data.frame(group=c(1, 1, 1, 1, 1,1, 2, 2, 2,2,2,2, 3,3,3,3,3,3),
                 date=c("2000-01-01", "2000-01-02", "2000-01-01", "2000-01-02", "2000-01-01", "2000-01-01",
                        "2000-01-03", "2000-01-04", "2000-01-05", "2000-01-03", "2000-01-04", "2000-01-05",
                        "2000-01-06", "2000-01-06", "2000-01-02", "2000-01-05", "2000-01-02", "2000-01-03"))
  </code></pre>
  
  <p>I basically have another time variable I want to compare with each "group", and if I have all the dates within a group on one row I should be able to (i.e. if "time" less than want_1 | want_2... etc. So something like this:</p>
  
  <pre><code>   group       date     want_1     want_2     want_3     want_4
  1      1 2000-01-01 2000-01-01 2000-01-02       &lt;NA&gt;       &lt;NA&gt;
  2      1 2000-01-02 2000-01-01 2000-01-02       &lt;NA&gt;       &lt;NA&gt;
  3      1 2000-01-01 2000-01-01 2000-01-02       &lt;NA&gt;       &lt;NA&gt;
  4      1 2000-01-02 2000-01-01 2000-01-02       &lt;NA&gt;       &lt;NA&gt;
  5      1 2000-01-01 2000-01-01 2000-01-02       &lt;NA&gt;       &lt;NA&gt;
  6      1 2000-01-01 2000-01-01 2000-01-02       &lt;NA&gt;       &lt;NA&gt;
  7      2 2000-01-03 2000-01-03 2000-01-04 2000-01-05       &lt;NA&gt;
  8      2 2000-01-04 2000-01-03 2000-01-04 2000-01-05       &lt;NA&gt;
  9      2 2000-01-05 2000-01-03 2000-01-04 2000-01-05       &lt;NA&gt;
  10     2 2000-01-03 2000-01-03 2000-01-04 2000-01-05       &lt;NA&gt;
  11     2 2000-01-04 2000-01-03 2000-01-04 2000-01-05       &lt;NA&gt;
  12     2 2000-01-05 2000-01-03 2000-01-04 2000-01-05       &lt;NA&gt;
  13     3 2000-01-06 2000-01-06 2000-01-02 2000-01-05 2000-01-03
  14     3 2000-01-06 2000-01-06 2000-01-02 2000-01-05 2000-01-03
  15     3 2000-01-02 2000-01-06 2000-01-02 2000-01-05 2000-01-03
  16     3 2000-01-05 2000-01-06 2000-01-02 2000-01-05 2000-01-03
  17     3 2000-01-02 2000-01-06 2000-01-02 2000-01-05 2000-01-03
  18     3 2000-01-03 2000-01-06 2000-01-02 2000-01-05 2000-01-03
  
  
  </code></pre>
  
  <p>Notice that each date within a group populated a new column. </p>
  
  <p>Also open to other suggestions, thanks!</p>