I have a dataset in a long format that I would like to reshape to wide. I normally know how to do it but the problem is with the variable names. The variables in the long format look like this:
| ID | time | WSAS_01 |
|---|---|---|
| 1 | 1 | 4 |
| 1 | 2 | 3 |
| 2 | 1 | 6 |
| 2 | 2 | 8 |
But after reshaping I would like the name of the variables to be like this, so that time 1 is _r1_ (and time 2 is _r2_) and it is in the middle of the name:
| ID | WSAS_r1_01 | WSAS_r2_01 |
|---|---|---|
| 1 | 4 | 3 |
| 2 | 6 | 8 |
Does anyone know how to do it?