Hi I have a dataset like this:
| ID | Gender | Group | Biomarker | Value | 
|---|---|---|---|---|
| 001 | Male | Test | CA125 | X1 | 
| 001 | Male | Test | CEA | X2 | 
| 001 | Male | Test | AFP | X3 | 
| 002 | Female | Control | CA125 | X4 | 
| 002 | Female | Control | CEA | X5 | 
| 002 | Female | Control | AFP | X6 | 
I want to merge all rows with the same id into a single row and change the column names to the biomarkers for example:
| ID | Gender | Group | CA125 | CEA | AFP | 
|---|---|---|---|---|---|
| 001 | Male | Test | X1 | X2 | X3 | 
| 002 | Female | Control | X4 | X5 | X6 | 
Some IDs might not have some of the biomarkers: I want them to have missing data in the final table*** Some IDs might have several values for a biomarker: I want them to have the minimum of the values
What should I do?
 
     
    