I have a data frame with 4 columns and I want to pivot it the following way:
ORIGINAL TABLE:
| RA | T | V | ES | 
|---|---|---|---|
| 01 | ee | 0 | AA | 
| 01 | dd | -1 | AA | 
| 01 | hh | 9 | AA | 
| 02 | ee | 0 | AA | 
| 02 | dd | 8 | AA | 
| 02 | hh | -2 | AA | 
| 03 | ee | 5 | BB | 
| 03 | dd | 3 | BB | 
| 03 | hh | 4 | BB | 
| 04 | ee | -7 | CC | 
| 04 | dd | 2 | CC | 
| 04 | hh | 0 | CC | 
DESIRED TABLE AFTER PIVOTING:
| RA | ee | dd | hh | ES | 
|---|---|---|---|---|
| 01 | 0 | -1 | 9 | AA | 
| 02 | 0 | 8 | -2 | AA | 
| 03 | 5 | 3 | 4 | BB | 
| 04 | -7 | 2 | 0 | CC | 
In the past I pivot a table with 3 columns and it worked just fine. This time, I want
RA to be the index
T to be the columns
V to be the values
ES to keep as is (as described above).
I would really appreciate any help.
Thanks!
 
    