title: How to "unmelt" data with reshape r
body: <p>I have a data frame that I melted using the reshape package that I would like to "un melt". </p>
  
  <p>here is a toy example of the melted data (real data frame is 500x100 or larger) :</p>
  
  <pre><code>variable&lt;-c(rep("X1",3),rep("X2",3),rep("X3",3))
  value&lt;-c(rep(rnorm(1,.5,.2),3),rep(rnorm(1,.5,.2),3),rep(rnorm(1,.5,.2),3))
  dat &lt;-data.frame(variable,value)
  dat
   variable     value
  1       X1 0.5285376
  2       X1 0.5285376
  3       X1 0.5285376
  4       X2 0.1694908
  5       X2 0.1694908
  6       X2 0.1694908
  7       X3 0.7446906
  8       X3 0.7446906
  9       X3 0.7446906
  </code></pre>
  
  <p>Each variable (X1, X2,X3) has values estimated at 3 different times (which in this toy example happen to be the same, but this is never the case). </p>
  
  <p>I would like to get it (back) in the form of :</p>
  
  <pre><code>     X1        X2        X3
  1 0.5285376 0.1694908 0.7446906
  2 0.5285376 0.1694908 0.7446906
  3 0.5285376 0.1694908 0.7446906
  </code></pre>
  
  <p>Basically, I would like the variable column to be sorted on ID (X1, X2 etc) and become column headings.  I have tried various permutations of cast, dcast, recast, etc.. and cant seem to get the data in the format that I want. It was easy enough to 'melt' data from the wide form to the longer form (e.g. the dat datset), but getting it back is proving difficult. Any ideas? I know this is relatively simple, but I am having a hard time conceptualizing how to do this in reshape or reshape2. </p>
  
  <p>Thanks,
  LP</p>