mirror_matrix | R Documentation |
Mirror a matrix horizontally
mirror_matrix(mat, MARGIN = 2)
mat |
(Matrix) A matrix object |
MARGIN |
(Integer) '1' mirrors the order of rows, '2' mirrors the order of columns. |
A version of 'mat' with its columns or rows in reversed order. Names are preserved if the matrix has any.
m <- matrix(1:6, ncol = 2, nrow = 3, byrow = FALSE)
m
#> [,1] [,2]
#> [1,] 1 4
#> [2,] 2 5
#> [3,] 3 6
# Just like apply(), MARGIN = 1 is rows and MARGIN = 2 is cols.
mirror_matrix(m, 2)
#> [,1] [,2]
#> [1,] 4 1
#> [2,] 5 2
#> [3,] 6 3
mirror_matrix(m, 1)
#> [,1] [,2]
#> [1,] 3 6
#> [2,] 2 5
#> [3,] 1 4
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.