Entering edit mode
                    10 months ago
        ARP
        
    
        ▴
    
    10
    Hi all,
I have a data frame with two columns representing one to many relationship values. Here is a snippet to generate the data as I have it:
get_genes <- function(i) paste0(sample(LETTERS[6:15], sample(3:7, 1), replace=TRUE)
                              , collapse = ";")
dummy_data <- data.frame(X1 = sample(LETTERS[1:5])
                       , X2 = sapply(1:5, get_genes)
                       )
Which would produce a dataframe similar to this:
  X1   X2
1  E   L;M;G
2  B   J;K;O
3  C   K;O;F
4  D   F;N;G;M
5  A   N;M
I need to transform that dataframe into an adjacency matrix like the example below. I have no idea how to go about it, though. I have played around with reshape2, but I can't find the right way to get what I need. Any solution will be greatly appreciated.
   X1 X2
1   E  L
2   E  M
3   E  G
4   B  J
5   B  K
6   B  O
7   C  K
8   C  O
9   C  F
10  D  F
11  D  N
12  D  G
13  D  M
14  A  N
15  A  M