I have the following dataset:
ID | Age |
---|---|
1 | 19 |
1 | 22 |
2 | 20 |
2 | 21 |
And I would like to turn it into this:
Age | ID=1 | ID=2 |
---|---|---|
19 | 1 | na |
20 | na | 1 |
21 | na | 1 |
22 | 1 | na |
How can I do that?
I have tried both with t() function and spread() but I was not able to arrive to a decent result