I've been working in SAS for a few years but as my time as a student with a no-cost-to-me license comes to an end, I want to learn R.
Is it possible to transpose a data set so that all the observations for a single ID are on the same line? (I have 2-8 observations per unique individual but they are currently arranged vertically rather than horizontally.) In SAS, I had been using PROC SQL and PROC TRANSPOSE depending on my analysis aims.
Example:
ID date timeframe fruit_amt veg_amt <br/>
4352 05/23/2013 before 0.25 0.75 <br/>
5002 05/24/2014 after 0.06 0.25 <br/>
4352 04/16/2014 after 0 0 <br/>
4352 05/23/2013 after 0.06 0.25 <br/>
5002 05/24/2014 before 0.75 0.25 <br/>
Desired:
ID B_fr05/23/2013 B_veg05/23/2013 A_fr05/23/2013 A_veg05/23/2013 B_fr05/24/2014 B_veg05/24/2014 (etc) <br/>
4352 0.25 0.75 0.06 0.25 . . <br/>
5002 . . . . 0.75 0.25 <br/>