flipdim.RdFlip matrices up and down or left and right; or circulating indices per dimension.
flipdim(a, dim)
flipud(a)
fliplr(a)
circshift(a, sz)flipdim will flip a matrix along the dim dimension, where
dim=1 means flipping rows, and dim=2 flipping the columns.
flipud and fliplr are simply shortcuts for flipdim(a, 1)
resp. flipdim(a, 2).
circshift(a, sz) circulates each dimension
(should be applicable to arrays).
the original matrix somehow flipped or circularly shifted.
a <- matrix(1:12, nrow=3, ncol=4, byrow=TRUE)
flipud(a)
#> [,1] [,2] [,3] [,4]
#> [1,] 9 10 11 12
#> [2,] 5 6 7 8
#> [3,] 1 2 3 4
fliplr(a)
#> [,1] [,2] [,3] [,4]
#> [1,] 4 3 2 1
#> [2,] 8 7 6 5
#> [3,] 12 11 10 9
circshift(a, c(1, -1))
#> [,1] [,2] [,3] [,4]
#> [1,] 10 11 12 9
#> [2,] 2 3 4 1
#> [3,] 6 7 8 5
v <- 1:10
circshift(v, 5)
#> [1] 6 7 8 9 10 1 2 3 4 5