I have the following dataframe:
long band d Ret
100 0 1 2.10
100 0 2 1.96
100 0 1 -1.10
100 0 2 0.96
100 0 1 0.54
100 0 2 -2.12
200 0 1 3.10
200 0 2 -1.96
200 0 1 5.66
200 0 2 2.22
200 0 1 -0.54
200 0 2 0.25
And I want to transform it so that Ret values that correspond to the same long/band/d columns are in a row such that:
long band d Ret1 Ret2 Ret3
100 0 1 2.10 -1.10 0.54
100 0 2 1.96 0.9. -2.12
200 0 1 3.10 5.66 -0.54
200 0 2 -1.96 2.22 0.25
I have tried 'transform' and melt but they don't have the condition to put the Rets side-by-side