I am trying to clean this dataset and the original data is formatted terribly. This is the format that the original data came in:
PATIENT_CODE PATIENT_NAME TEST TEST_RESULT
1 JOHN SMITH URIC ACID 5
1 JOHN SMITH GLUCOSE 6
This is the format I would like to use:
PATIENT_CODE PATIENT_NAME URIC ACID GLUCOSE
1 JOHN SMITH 5 6
There are 10+ tests ("TEST" variable) for each patient, and not all patients received all of the tests. How do I "unmelt" this data to get the desired dataset?