Expand Matrix
Examples
A <- matrix(c(
0, 1, 1,
0, 0, 1,
1, 0, 0
), byrow = TRUE, ncol = 3, nrow = 3)
rownames(A) <- letters[1:NROW(A)]
colnames(A) <- rownames(A)
label <- sort(rep(rownames(A), 2))
expand_matrix(A, label, loops = FALSE, normalize = TRUE)
#> [,1] [,2] [,3] [,4] [,5] [,6]
#> a 0.0 0.0 0.5 0.5 0.5 0.5
#> a 0.0 0.0 0.5 0.5 0.5 0.5
#> b 0.0 0.0 0.0 0.0 0.5 0.5
#> b 0.0 0.0 0.0 0.0 0.5 0.5
#> c 0.5 0.5 0.0 0.0 0.0 0.0
#> c 0.5 0.5 0.0 0.0 0.0 0.0