Numeric attributes are being alpha-sorted in ggnet2

270 views Asked by At

I've built a dependency graph using ggnet2 and am trying to set the size of the vertex based on Cost, which is a numeric attribute in the node data structure.

enter image description here

The issue is calling the method set.vertex.attribute.

x = data.frame(ID = network.vertex.names(deps))
for (i in names(df)) {
  y = merge(x, df, by = "ID", sort = F)[,i]
  set.vertex.attribute(deps, i, as.character(y))
}

If I passing an integer, it complains that Inappropriate value given in set.vertex.attribute. A similar issue was reported here

1

There are 1 answers

0
andyczerwonka On

If I remove the loop and add the attribute for the whole vector, all is well.

set.vertex.attribute(deps, "Cost", df$Cost)