My dataset is as follows, I want to create a network but the error is that my adjacency matrix is not symmetric, I am new to R, I don't know how to convert my data to symmetric adjacency matrix, can any one help me please?
df2:
17 "RobertKennedyJr" "RobertKennedyJr "
18 "Real_Sheezzii" "Real_Sheezzii "
19 "Kellie_Martin" "Kellie_Martin "
20 "ThatsOurWaldo" "ThatsOurWaldo "
21 "SCN_Nkosi" "SCN_Nkosi "
22 "azsweetheart013" "azsweetheart013 "
23 "KYourrights" "KYourrights KathyConWom"
24 "GowTolson" " KathyConWom"
25 "Peterpu52451065" " KathyConWom"
26 "Jifchoppa" " KathyConWom"
27 "ClaraLpz3" " KathyConWom"
28 "Anna5705" " KathyConWom"
29 "Brizzle254" " KathyConWom"
30 "JackSpa02102454" " KathyConWom"
The code that I tried
library("igraph")
library("network")
library("statnet")
relationsp <- as.matrix(df2)
relationsp
net <- as.network(x = mat, # the network object
directed = TRUE, # specify whether the network is directed
loops = FALSE, # do we allow self ties (should not allow them)
matrix.type = "adjacency" # the type of input
)
If you are applying
igraph
package, you should usegraph_from_data_frame
to create the graph objectnet
, which is followed byget.adjacency
to obtain the adjacency matrix, e.g.,