I have dataframe shaped like the following:
| country | institution | department | individual |
|---|---|---|---|
| USA | Apple | Marketing | John Fowler |
| UK | Apple | Marketing | Peter Pan |
| China | Apple | Finance | John Fowler |
| Argentina | Bosch | Marketing | Messi |
I would like to create a weighted adjacency matrix that looked like the following:
| USA | UK | China | Argentina | Apple | Bosch | Marketing | Finance | John Fowler | Peter Pan | Messi | |
|---|---|---|---|---|---|---|---|---|---|---|---|
| USA | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 0 |
| UK | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 1 | 0 |
| China | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 1 | 0 | 0 |
| Argentina | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 1 |
| Apple | 1 | 1 | 1 | 0 | 0 | 0 | 2 | 1 | 2 | 1 | 0 |
| Bosch | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 1 |
| Marketing | 1 | 1 | 0 | 1 | 2 | 1 | 0 | 0 | 1 | 1 | 1 |
| Finance | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 |
| John Fowler | 1 | 0 | 1 | 0 | 2 | 0 | 1 | 1 | 0 | 0 | 0 |
| Peter Pan | 0 | 1 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 |
| Messi | 0 | 0 | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 0 | 0 |
I have seen examples here and here but I could not extend the solutions to more than 2 columns.
