title: Combining rows into one row with multiple columns of data R
body: <p>I have a dataset that measures pre and post weight conditions. I was trying to combine rows with similar ID's to one row and create two additional columns to show the results for pre and post for each ID.</p>
  <p>Original table</p>
  <pre>
  
  ID  Sex         Race        TIME    SH           PRE_WEIGHT POST_WEIGHT
  1   FEMALE      White       POST    Poor         168            152
  1   FEMALE      White       PRE     Good         168            152
  2   MALE        Hispanic    POST    Very Poor    157            143
  2   MALE        Hispanic    PRE     Poor         157            143
  3   FEMALE      Black       POST    Good         129            118
  3   FEMALE      Black       PRE     Satisfactory 129            118
  
  </pre>
  <p>Results should look like this:</p>
  <pre>
  
  ID  Sex         Race        TIME    SH          PRE_WEIGHT  POST_WEIGHT TIME_PRE    TIME_POST   SH_PRE      SH_POST
  1   FEMALE      White       POST    Poor        168         152         POST        PRE         Poor        Good
  2   MALE        Hispanic    POST    Very Poor   157         143         POST        PRE         Very Poor   Poor
  3   FEMALE      Black       POST    Good        129         118         POST        PRE         Good        Satisfactor
  
  </pre>
  <p>I tried to do it with reshape which is very slow and didn't work. I also wasn't able to reshape the table with tidyr.</p>
  <p>Hope anyone can help me with this.</p>