Apologies to my classmates for the multipe postings.
I am preparing to reshape my data from long to wide.
This is what I have:
| pt_id OD OS visit1 |
|--------------------------------------|
7. | 702337 20/50 1 |
8. | 702337 20/30 1 |
9. | 702337 20/40-2 1 |
10. | 702337 20/25 2 |
11. | 702337 20/60 2 |
This is where I am headed:
| pt_ID | OD1 | OS1 | OD2 | OS2 |
| 702377 | 20/40-2 | 20/30 | 20/60 | 20/25 |
OD: right eye, OS: left eye
However, you see in my long data that there are 2 readings for the right eye (OD) on the first visit.
This happens for a few patients throughout my dataset.
I need to keep 2 readings per 1 visit: 1 from the right eye and 1 from the left eye.
What I need to do is take the "latest" reading (row furthest down) for either eye, meaning I need to drop the earlier readings for all patients who have more than 1 reading in 1 eye for any single visit.
How can I go about doing so?
Thank you for your help!