I need to change/invert rows in my data frame, not transposing the data but moving the bottom row to the top and so on. If the data frame was:
1 2 3
4 5 6
7 8 9
I need to convert to
7 8 9
4 5 6
1 2 3
I’ve read about sort() but I don’t think it is what I need or I’m not able to find the way.
There probably are more elegant ways, but this works:
This works because you are indexing the matrix with a reversed sequence of integers as the row index.
nrow(m):1results in3 2 1.