title: Reshaping data from long to wide with multiple categories
body: <p>I'm trying to reshape my data from a long format into a wide format based on multiple groupings, without success. with this data:</p>
  
  <pre><code>id &lt;- 1:20
  month &lt;- rep(4:7, 50)
  name &lt;- rep(c("sam", "mike", "tim", "jill", "max"), 40)
  cost &lt;- sample(1:100, 200, replace=TRUE)
  df &lt;- data.frame(id, month, name, cost)
  
  df.mo.mean &lt;- aggregate(df$cost ~ df$name + df$month, FUN="mean")
  df.mo.sd &lt;- aggregate(df$cost ~ df$name + df$month, FUN="sd")
  
  df.mo &lt;- data.frame(df.mo.mean, df.mo.sd)
  df.mo &lt;- df.mo[,-c(4,5)]
  df.mo[3:4] &lt;- round(df.mo[3:4],2)
  
  head(df)
     id month name cost
  1  1     4  sam   29
  2  2     5 mike   93
  3  3     6  tim   27
  4  4     7 jill   67
  5  5     4  max   28
  6  6     5  sam   69
  </code></pre>
  
  <p>I'm trying to get my data to look like something below, and try to generalize it for an unknown number of names (but &lt;15 max)</p>
  
  <pre><code>month    name1.cost.mean  name1.cost.sd  name2.cost.mean  name2.cost.sd
  1        45               4              40               6
  2        ...   
  </code></pre>
  
  <p>I've tried <code>reshape</code> and <code>do.call</code> with <code>rbind</code> without success. The only other way I can think of doing it is with a loop, which means I'm doing something wrong. I dont have any experience with <code>plyr</code> and would prefer to solve this problem with base packages (for learning purposes), but if its not possible any other suggestions would be very helpful</p>