I have a database in which I have several different emotion variables for two task conditions, for example:
ID Cond1_sad Cond1_anxious Cond1_happy Cond2_sad Cond2_anxious Cond2_happy
1 C_01 1 7 4 1 3 2
2 C_02 3 6 4 4 6 5
3 C_03 8 6 5 3 4 4
4 C_04 4 5 5 6 8 6
5 C_05 6 4 3 2 6 3
6 C_06 1 4 2 8 1 4
I need to stack according to condition, but keep emotion variables in separate columns. For example:
ID Condition Sad Anxious Happy
1 C_01 1 1 7 4
2 C_02 1 3 6 4
3 C_03 1 8 6 5
4 C_04 1 4 5 5
5 C_05 1 6 4 3
6 C_06 1 1 4 2
7 C_01 2 1 3 2
8 C_02 2 4 6 5
9 C_03 2 3 4 4
10 C_04 2 6 8 6
11 C_05 2 2 6 3
12 C_06 2 8 1 4
I have tried various options for stacking the data (e.g. melting them), but end up with all the variables stacked on top of one another. Is there a better solution?
Many thanks in advance.