0

I'm trying to make a connectogram using code that's worked for me before but for some reason I'm having issue with the color of the vertices

plot(net, edge.width=sqrt(links$weight), edge.arrow.size=0, 
     edge.lty=1, arrow.mode=0, vertex.size=10,
     vertex.label=nodes$Name, vertex.label.dist=1.3, 
     vertex.label.cex=1.2, vertex.label.degree=-pi/4, 
     vertex.color=nodes$Team, layout=layout_in_circle)

The error I'm getting is Error in symbols(x = coords[, 1], y = coords[, 2], bg = vertex.color, : invalid color name 'Biomarkers'

Biomarkers is one of the variables in the Teams column. I'm attaching figures that are generated when I take out the vertex.color piece, so I know the rest of it works, and when I get this error (ignore the label overlap, I'll fiddle with that later)

Connectogram2

Connectogram

G5W
  • 36,531
  • 10
  • 47
  • 80
EmilyLars
  • 13
  • 1
  • 4
  • 2
    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 Mar 30 '22 at 23:21
  • Without your data, we cannot know for sure, but it looks like nodes$Team is a character variable, strings. If you got it to work for you before, you probably had Teams as a factor variable (which would be interpreted as integers). You might try `nodes$Team=as.factor(nodes$Team)` before calling your plot statement. – G5W Mar 30 '22 at 23:25
  • Ah yep, needed to be a factor, thanks! – EmilyLars Mar 31 '22 at 00:55

1 Answers1

0

This is the error message that you would get if nodes$Team is a character variable, i.e. strings. You can get around this by making Team into a factor variable.

nodes$Team=as.factor(nodes$Team)
G5W
  • 36,531
  • 10
  • 47
  • 80