symmetricize: Make a matrix symmetric

Description Usage Arguments Value Author(s) Examples

Description

Make the matrix symmetric by making all "mirrored" positions consistent. A variety of methods are provided to make the matrix symmetrical.

Usage

1
2
symmetricize(matrix, method = c("max", "min", "avg", "ld", "ud"),
  adjacencyList = FALSE)

Arguments

matrix

The matrix to make symmatric

method

The method to use to make the matrix symmetric. Default is to take the maximum.

  • "max" For each position, m_{i,j}, use the maxiumum of (m_{i,j}, m_{j,i})

  • "min" For each position, m_{i,j}, use the minimum of (m_{i,j}, m_{j,i})

  • "avg" For each position, m_{i,j}, use the mean: (m_{i,j} + m_{j,i})/2

  • "ld" Copy the lower triangular portion of the matrix to the upper triangular portion.

  • "ud" Copy the upper triangular portion of the matrix to the lower triangular portion.

adjacencyList

Logical. If false, returns the symmetric matrix (the same format as the input). If true, returns an adjacency list representing the upper triangular portion of the adjacency matrix with addressing based on the row.names of the matrix provided.

Value

The symmetric matrix

Author(s)

Jeffrey D. Allen Jeffrey.Allen@UTSouthwestern.edu

Examples

1
2
3
4
5
6
7
8
#Create a sample 3x3 matrix
mat <- matrix(1:9, ncol=3)

#Copy the upper diagonal portion to the lower
symmetricize(mat, "ud")

#Take the average of each symmetric location
symmetricize(mat, "avg")

theboocock/coco documentation built on May 31, 2019, 9:10 a.m.