hello, I have a database where there are subjects with several observations and I would like to make a database where there is a single observation for each id
but I would like that for certain variables there are 2 columns (one for each value), how can it be done?
I put a reprex
this is similar to what I have
id | a | b | c | d | e |
---|---|---|---|---|---|
1 | 1 | 2 | 3 | 4 | 4 |
2 | 1 | 2 | 3 | 5 | 1 |
2 | 1 | 2 | 3 | 4 | 1 |
3 | 1 | 2 | 3 | 6 | 2 |
4 | 1 | 2 | 3 | 1 | 3 |
5 | 1 | 2 | 3 | 2 | 4 |
5 | 1 | 2 | 3 | 3 | 5 |
And this is what I want
id | a | b | c | d_1 | d_2 | e_1 | e_2 |
---|---|---|---|---|---|---|---|
1 | 1 | 2 | 3 | 4 | 4 | ||
2 | 1 | 2 | 3 | 5 | 4 | 1 | 1 |
3 | 1 | 2 | 3 | 6 | 2 | ||
4 | 1 | 2 | 3 | 1 | 3 | ||
5 | 1 | 2 | 3 | 2 | 3 | 4 | 5 |