How to create an igraph object from an adjacency matrix

60 Views Asked by At

I wanted to create an igraph dataset in R to analyze the social networks I coded in the original adjacency matrix. Below you'll find the code I used:

returnees_data <- read.table(
  "Returnees_Test1.csv", 
  sep=";", stringsAsFactors=FALSE, row.names=1)

returnees_i <- graph_from_adjacency_matrix(
  returnees_data,
  mode = c("undirected"),
  weighted = TRUE,
  diag = FALSE) 

When I ran the second command, R responded

Error in mde(x) : 'list' object cannot be coerced to type 'double'.

I tried the unlist() command, but that didn't worked and I couldn't find another suitable solution...Now I don't know if the problem is in my code or in my data, since the following commands worked:

gplot(returnees_data,
      gmode="graph",       # type of network: undirected
      mode="kamadakawai",  # how the nodes are positioned
      vertex.cex=.8,       # the size of the node shapes
      usearrows=FALSE,     #no arrows
      displaylabels=TRUE,  # to add the node labels
      label.pos=1,        # labels below the node shapes
      label.cex=.5,        # size of the node labels
      edge.col="grey70")   # color of ties 70% white

sna::degree(returnees_data, gmode="graph") 
0

There are 0 best solutions below