Hi,
I needed help with reshaping my data. I initially had data that looks like this:
There are proximity groups and towns in each group. a town can be present in more than one group and each group can have a different number of towns.
I did reshape wide and got this result.
I would ideally like 3 rows for each group_id such that each row has pairs of towns
Could you help with how to achieve this?
Thanks!
I needed help with reshaping my data. I initially had data that looks like this:
| group_id | town_id | income |
| 1 | 1 | |
| 1 | 2 | |
| 1 | 3 | |
| 2 | 4 | |
| 2 | 3 | |
| 2 | 2 |
I did reshape wide and got this result.
| group_id | town_id1 | income1 | town_id2 | income2 | town_id3 | income3 |
| 1 | 1 | 2 | 3 | |||
| 2 | 4 | 3 | 2 |
| group_id | town_id1 | income1 | town_id2 | income2 |
| 1 | 1 | 2 | ||
| 1 | 2 | 3 | ||
| 1 | 3 | 1 | ||
| 2 | 4 | 3 | ||
| 2 | 3 | 2 | ||
| 2 | 4 | 2 |
Thanks!

Comment