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
We can reverse the order of row.names (for data.frame only):
# create data.frame m <- matrix(1:9, ncol=3, byrow=TRUE) df_m <- data.frame(m) #reverse df_m[rev(rownames(df_m)), ] # X1 X2 X3 # 3 7 8 9 # 2 4 5 6 # 1 1 2 3