reorder_mat {graph4lg} | R Documentation |
Reorder the rows and columns of a symmetric matrix
Description
The function reorders the rows and columns of a symmetric matrix according to a specified order.
Usage
reorder_mat(mat, order)
Arguments
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 |
Details
The matrix mat
must be symmetric and have rows and columns
names. Its values are not modified.
Value
A reordered symmetric matrix
Author(s)
P. Savary
Examples
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)
[Package graph4lg version 1.8.0 Index]