Combine several connectivity matrices
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
).
append_matrix(..., na_to_zero = TRUE)
...
: 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
.A connectivity matrix of dimensions n x n
, where n
is the total number of unique nodes across all provided matrices.
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)