I have a dataframe that looks like so:
|
Q1_2008_East |
Q1_2008_West |
Q2_2008_East |
Q2_2008_West |
...... |
Q4_2012_West |
A |
|
|
12 |
8 |
...... |
14 |
B |
14 |
12 |
3 |
4 |
...... |
7 |
This is just for example, whereas mine has many more columns each containing (1) a quarter of the year, (2) the year, and (3) the location (in this case East and West).
I would like to format the data long like so:
|
Q1 |
Q2 |
Q3 |
2008 |
2009 |
... |
East |
Total |
A |
1 |
0 |
0 |
1 |
0 |
... |
1 |
0 |
A |
0 |
1 |
0 |
1 |
0 |
... |
1 |
12 |
B |
1 |
0 |
0 |
1 |
0 |
... |
1 |
14 |
B |
0 |
1 |
0 |
1 |
0 |
... |
0 |
4 |
... |
... |
... |
... |
... |
... |
... |
... |
... |
I have been trying to find a way to use the reshape function with data like this, but I am at a loss. Any ideas or suggestions would be greatly appreciated.
0 Response to Reshape wide to long over various attributes
Post a Comment