rot90.RdRotate matrices for 90, 180, or 270 degrees..
rot90(a, k = 1)Rotates a numeric or complex matrix for 90 (k = 1), 180 (k = 2) or 270 (k = 3 or k = -1) degrees.
Value of k is taken mod 4.
the original matrix rotated
a <- matrix(1:12, nrow=3, ncol=4, byrow=TRUE)
rot90(a)
#> [,1] [,2] [,3]
#> [1,] 4 8 12
#> [2,] 3 7 11
#> [3,] 2 6 10
#> [4,] 1 5 9
rot90(a, 2)
#> [,1] [,2] [,3] [,4]
#> [1,] 12 11 10 9
#> [2,] 8 7 6 5
#> [3,] 4 3 2 1
rot90(a, -1)
#> [,1] [,2] [,3]
#> [1,] 9 5 1
#> [2,] 10 6 2
#> [3,] 11 7 3
#> [4,] 12 8 4