I want to create an Adjancey Matrix from a non-square matrix. The rows and columns both define different variables. In the example row represents unique funds where column represents unique firms.
This code creates 10x10 matrix with repeated values where as I want to create 6x6 matrix as shown below
expand.matrix <- function(A){
m <- nrow(A)
n <- ncol(A)
B <- matrix(0,nrow = m, ncol = m)
C <- matrix(0,nrow = n, ncol = n)
cbind(rbind(B,t(A)),rbind(A,C))
}
df <- expand.matrix(dat)
Converting not a Square weighted adjacency matrix to igraph object in R
My matrix is
dat <- structure(c(0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1,
1), .Dim = c(3L, 6L), .Dimnames = structure(list(c("Fund 1",
"Fund2", "Fund3"), c("Firm A", "Firm B", "Firm C", "Firm D",
"Firm E", "Firm F")), .Names = c("", "")), class = "table")
Expected results