0

I am using code from this post: Order of treechart entries not correct in R igraph package

The code does not work if labels are all / mostly numeric:

111
    222
    333
        99
        1010
    44
    55
    66
        1111
            1313
            1414
            1515
    77
    88
        1212

Following is the error:

Error in if (vr[1] == vr[2]) { : missing value where TRUE/FALSE needed
In addition: Warning messages:
1: In mean.default(sapply(nb, function(x) calcypos(g, x))) :
  argument is not numeric or logical: returning NA
2: In mean.default(sapply(nb, function(x) calcypos(g, x))) :
  argument is not numeric or logical: returning NA
3: In mean.default(sapply(nb, function(x) calcypos(g, x))) :
  argument is not numeric or logical: returning NA
4: In mean.default(sapply(nb, function(x) calcypos(g, x))) :
  argument is not numeric or logical: returning NA
5: In mean.default(sapply(nb, function(x) calcypos(g, x))) :
  argument is not numeric or logical: returning NA
6: In mean.default(sapply(nb, function(x) calcypos(g, x))) :
  argument is not numeric or logical: returning NA
7: In mean.default(sapply(nb, function(x) calcypos(g, x))) :
  argument is not numeric or logical: returning NA
8: In mean.default(sapply(nb, function(x) calcypos(g, x))) :
  argument is not numeric or logical: returning NA
9: In mean.default(sapply(nb, function(x) calcypos(g, x))) :
  argument is not numeric or logical: returning NA
10: In mean.default(sapply(nb, function(x) calcypos(g, x))) :
  argument is not numeric or logical: returning NA
> 

The 'edges' dataframe in code is being made all right (I checked with print(edges)). How can I solve this problem? Thanks for your help.

Jaap
  • 81,064
  • 34
  • 182
  • 193
rnso
  • 23,686
  • 25
  • 112
  • 234
  • I am not sure what you mean. The word "label" does not even appear in the cited post. – Gabor Csardi Jul 25 '14 at 11:23
  • By labels I meant 111, 222, 333, 99 etc which should appear on the chart as AAA, BBB etc appeared on http://stackoverflow.com/questions/24948003/order-of-flowchart-treemap-entries-not-correct-in-r-igraph-package/24950271 – rnso Jul 25 '14 at 13:14

1 Answers1

0

I would write this as a comment, but that does not allow structured code. Numbers as labels work fine in igraph:

library(igraph)
g <- graph.ring(9)
V(g)$label <- as.character(seq(111, 999, by=111))
plot(g)

enter image description here

Maybe you are adding vertex names, and not converting them the characters? It you specify vertices as numbers (i.e. of mode numeric), then igraph treats them as numeric vertex id, not as symbolic vertex names.

Anyway, whatever you want to use as label for plotting, assign it as the label vertex attribute.

Gabor Csardi
  • 10,705
  • 1
  • 36
  • 53