In Matlab, I know there are some functions that can flip matrix, say flip left and right (horizontal) or up and down (vertical), but I have no idea if there are similar ones in R.
For example, assuming we have a matrix m <- matrix(1:12,nrow = 3)
, we want
- Horizontal flip to get
mh
[,1] [,2] [,3] [,4]
[1,] 10 7 4 1
[2,] 11 8 5 2
[3,] 12 9 6 3
- Vertical flip to get
mv
[,1] [,2] [,3] [,4]
[1,] 3 6 9 12
[2,] 2 5 8 11
[3,] 1 4 7 10