reorder_mat | R Documentation |
The function reorders the rows and columns of a symmetric matrix according to a specified order.
reorder_mat(mat, order)
mat |
An object of class |
order |
A character vector with the rows and columns names of the matrix
in the order in which they will be ordered by the function. All its elements
must be rows and columns names of the matrix |
The matrix mat
must be symmetric and have rows and columns
names. Its values are not modified.
A reordered symmetric matrix
P. Savary
mat <- matrix(rnorm(36), 6) mat[lower.tri(mat)] <- t(mat)[lower.tri(mat)] row.names(mat) <- colnames(mat) <- c("A", "C", "E", "B", "D", "F") order <- c("A", "B", "C", "D", "E", "F") mat <- reorder_mat(mat = mat, order = order)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.