0

My code is the following:

D_igraph <- graph_from_data_frame(d = edges, vertices = nodes, directed = FALSE)
as.numeric(Strength1)
set.graph.attribute(D_igraph, "Strength_of_tie", Strength1)
D
E(D_igraph)$Strength <- Strength1
plot(D_igraph, vertex.label.color="black",
     edge.color=c("yellow","pink", "green","blue", "violet")) 
MrFlick
  • 195,160
  • 17
  • 277
  • 295
  • 1
    It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. – MrFlick Jun 11 '20 at 20:06
  • Okay sure thing, thanks. – DataNewcomer Jun 12 '20 at 15:57
  • Essentially i have an edge attribute variable, Strength, which i want to color code based on the strength value (1,2,3,4,5) in the igraph but am unsure how to do this. it is currently coded as a character edge attribute for the vertex (nodes) which are schools. It looks like "1" "5" "3" etc for all 49 or so ties. Any help would be great! – DataNewcomer Jun 12 '20 at 15:59
  • tie_type_colors = c("yellow", "violet", "skyblue", "pink", "green") E(D_igraph)$Strength[ E(D_igraph)$Strength==1 ] = tie_type_colors[1] E(D_igraph)$Strength[ E(D_igraph)$Strength==2 ] = tie_type_colors[2] E(D_igraph)$Strength[ E(D_igraph)$Strength==3 ] = tie_type_colors[3] E(D_igraph)$Strength[ E(D_igraph)$Strength==4 ] = tie_type_colors[4] E(D_igraph)$Strength[ E(D_igraph)$Strength==5 ] = tie_type_colors[5] plot(D_igraph) – DataNewcomer Jun 12 '20 at 16:35

0 Answers0