I'm trying to reshape a longitudinal dataset containing visual measurements for the left and right eyes of several individuals over a one year period. I need to end up with a data.frame() with the headings 'patient','month','re','le' (where 're' means 'right eye' and 'le' means 'left eye')
My data are currently in the format:
patient','re_month1','le_month1','re_month2','le_month2'....'le_month12'
I know I could use the reshape() function to sort the data if I only had one piece of data per time point. If I were just working with 'patient','month1','month2' etc, I could use the following:
reshape(dframe,idvar = 'patient',v.names = 'vision',
varying = 2:13,direction = "long")
...But how do I do this when there are two pieces of data (or more) at each time point?