append_matrix {chessboard}R Documentation

Combine several connectivity matrices

Description

Combines different connectivity matrices by row names and column names by performing a 2-dimensional full join. Missing edges are filled with 0 (default) or NA (argument na_to_zero).

Usage

append_matrix(..., na_to_zero = TRUE)

Arguments

...

one or several matrix objects created by connectivity_matrix().

na_to_zero

a logical value. If TRUE (default) missing edges are coded as 0. Otherwise they will be coded as NA.

Value

A connectivity matrix of dimensions ⁠n x n⁠, where n is the total number of unique nodes across all provided matrices.

Examples

mat1 <- matrix(rep(1, 9), nrow = 3)
colnames(mat1) <- c("A", "B", "C")
rownames(mat1) <- c("A", "B", "C")
mat1

mat2 <- matrix(rep(1, 9), nrow = 3)
colnames(mat2) <- c("D", "E", "F")
rownames(mat2) <- c("D", "E", "F")
mat2

mat3 <- matrix(rep(1, 9), nrow = 3)
colnames(mat3) <- c("F", "G", "H")
rownames(mat3) <- c("F", "G", "H")
mat3

append_matrix(mat1, mat2, mat3)

append_matrix(mat1, mat2, mat3, na_to_zero = FALSE)

[Package chessboard version 0.1 Index]