Error in IGRAPH : help with graph node shape parameters ...

Hello to all,

I managed to get a social network of interactions between individuals from the following code:

#Layout Options
set.seed(3952) # set seed to make the layout reproducible
layout1 <- layout.fruchterman.reingold(go_Graph)

#Node or Vetex Options: Size and Color
V(go_Graph)$color <- "grey"
V(go_Graph)[degree(go_Graph, mode="in")>5]$color <- "yellow" #Destinguishing High Degree Nodes as yellow
V(go_Graph)$size=degree(go_Graph, mode = "in")*2

  #Edge Options: Color
  E(go_Graph)$color <- "grey"

  plot(go_Graph, 
       edge.arrow.size=0.25,
       edge.arrow.mode = "-",
       vertex.label.color= "black")

BUT I also have another df (named go_sexes) with the different nodes ID and the "sex" atribute. I changed it from chr to factor with two layer (Male = M and female = F)

I would like now to make my nodes became a square if it's a male and a circle if it's a female.

I tested as following in "#Node or Vetex Options: Size and Color" section of my script :

V(go_Graph)$shape <- ifelse(go_sexes[V(go_Graph), 2] == "M", "circle", "square") and I have the error : "Error in [<-.igraph.vs(*tmp*, oob, value = NA_integer_) :
invalid indexing"

can someone help me please ?? :smile:

Have a great day.

Hugo

Can you provide a reprex, please? See the FAQ.

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.