I have the raw data of different people working for different universities at the same time, e.g.:
UniA UniB UniC UniD
individual_A X NA X NA
individual_B NA X NA X
individual_C NA X NA NA
individual_D X X X NA
And I try to use this data to establish a weighted undirect network betweeen universities. In other words, I would like to generate an adjacency matrix corresponding to the below given example:
UniA UniB UniC UniD
UniA 0 1 2 0
UniB 1 1 1
UniC 0 0
UniD 0
How would this be possible in R. Any tips or pointers would be most appreciated.
Thank you in advance for your time and help.
EDIT: Can you help to reshape the data
position1 position2 position3 position4
individual_A UniA UniC NA NA
individual_B UniB UniD NA NA
individual_C UniB NA NA NA
individual_D UniA UniB UniC NA
I tried to use the package reshape melt() and cast() converting the data to the form like I showed before:
UniA UniB UniC UniD
individual_A X NA X NA
individual_B NA X NA X
individual_C NA X NA NA
individual_D X X X NA
However, the value in the raw data is actually string (uniA/ uniB....), the transform is not successful. please help.