4
I have this data frame:
> head(df1)
data spread
1 2006-01-01 -3.0404577
2 2006-02-01 -3.3902628
3 2006-03-01 -2.5283960
4 2006-04-01 -1.5279234
5 2006-05-01 -0.0897918
6 2006-06-01 1.0286549
> tail(df1)
data spread
112 2015-04-01 -0.2923391
113 2015-05-01 -0.8202538
114 2015-06-01 -1.0975489
115 2015-07-01 -1.1600462
116 2015-08-01 -0.4637534
117 2015-09-01 1.2141885
I want to reverse column and data order:
I made that command:
df1<-df1[order(rev(df1$data),rev(df1$spread)),]
It scrambles and leaves disorganized:
> head(df1)
data spread
114 jun2015 -1.09754890
110 fev2015 0.06755755
106 out2014 0.87560496
116 ago2015 -0.46375344
117 set2015 1.21418847
111 mar2015 0.32772727
> tail(MatrizVerticeSpreadMensala)
data spread
9 set2006 0.0742353
3 mar2006 -2.5283960
4 abr2006 -1.5279234
5 mai2006 -0.0897918
7 jul2006 0.5451561
1 jan2006 -3.0404577
Any suggestions?
Thank you!
The answer is not necessarily correct: 1. AP asked to invert the column, not sort differently. It really seems to have the same result, but it was not the question, for a person looking only how to reverse the order would be wrong. 2. He also asked to invert the columns, in this case only the order of the rows has been modified.
– Molx
Understood, as soon as I can I will correct the reply. Thank you!
– Jean