title: Reshaping data in R from long to wide format without aggregation
body: <p>I am working on a project, where I have a file which is in long format with 131170 objects and 4 variables; not all the values are numeric , and I have been trying to use the dcast function from reshape2 but how ever I try it gives me the error that the Aggregation function missing: defaulting to length. I do not want my data to be changed I simply want to change the format of the file.  </p>
  
  <p>This is the function I have written </p>
  
  <pre><code>W_data1 &lt;- dcast(L_data1, formula = ID + Date ~ Metric, value.var = "Value") 
  </code></pre>
  
  <p>This is an example of how my file looks like. </p>
  
  <pre><code>ID     Date       Metric     Value
  1003    3/5/2001    Age       74
  1003    3/5/2001    Age       74
  1003    3/5/2001    Age       74
  1003    3/5/2001    Age       74
  1003    3/5/2001    Sex        F
  1003    3/5/2001    Sex        F
  1003    3/5/2001    Sex        F
  1003    3/5/2001    Sex        F
  1003    3/5/2001    Dx         MM
  1003    3/5/2001    Dx         MM
  1003    3/5/2001    Dx         MM
  1003    3/5/2001    Dx         MM
  1003    3/5/2001    ISS.Stage   1
  </code></pre>
  
  <p>The wide format should look like this:</p>
  
  <pre><code>ID      Age Sex Dx  Date       ISS Stage    Heavy Chain Isotype
  1003    74  F   MM  3/5/2001    1           IgA
  1003    74  F   MM  3/5/2001    1           IgA
  1003    74  F   MM  3/5/2001    1           IgA
  1003    74  F   MM  3/5/2001    1           IgA
  1004    79  F   MM  1/1/1997    Unknown     N/A
  </code></pre>
  
  <p>there are multiple data for each ID some may have 4 sets of data and others just one.
  the reason why the ID's are repeating is because the same variables have different values on different dates for the same ID. </p>