I have an igraph object, which is basically a sparse matrix with both columns and rows labeled by id. I also have a data frame with row labels and a community value. I am trying to subset the adjacency matrix by selecting all rows and columns that match the row labels in the community data frame of some specific value.
I've tried various approaches with match, plyr, and subset, but cannot get anything to work. Below are two subsets of the data.
match(g2, communi)
>g2[1:3,1:3]
3 x 3 sparse Matrix of class "dgCMatrix"
568120 711503 1077594
568120 . 7 4
711503 7 . 4
1077594 4 4 .
> head(communi)
communi
568120 7
711503 7
1077594 7
1078147 7
772988 464
757866 72
