2

i've seen already the topic on the subjet with this issue :

library(ggraph)
library(igraph)
edges <- flare$edges
vertices <- flare$vertices
mygraph <- graph_from_data_frame(edges, vertices=vertices)

ggraph(mygraph, layout = 'circlepack', weight = 'size')
Error in tree_to_hierarchy(graph, direction, sort.by, weight) :
Weight must be numeric

Removing the quotations on size doesn't do the trick for me and it's the only solution i found so far !

Thank you for your help.

  • I ran into the same error as you with the circlepack example. Running the piece of code from @xiaoshi worked for me. R version 4.0.3 on windows 10. – Taylor White Jan 26 '21 at 18:12

2 Answers2

1

The ggraph package follow the ggplot2 logic. Are you looking for something like this ?

ggraph(graph, 'circlepack',weight=size) + 
    geom_node_circle( n = 50) + 
    coord_fixed()

enter image description here

EDIT: I have the R version: 4.0.0

And to get the version of ggraph, you can do: packageVersion("ggraph") and I have 2.0.3.

John Smith
  • 1,604
  • 4
  • 18
  • 45
  • edges <- flare$edges vertices <- flare$vertices ggraph(graph, 'circlepack',weight=size) + geom_node_circle( n = 50) + coord_fixed() it return this error : Erreur : No layout function defined for objects of class function – louis devresse Jun 06 '20 at 16:39
  • I added the graph. Did you expect this graph ? Maybe you have to check the versions (of R, of ggraph, etc.) cf my edits in my answer. – John Smith Jun 06 '20 at 20:13
  • 1
    Thank you so far ! So I have the version 4.0.0 of R (I checked it with the "version" command) and the version 2.0.3 of ggraph and as you talked about ggplot2 I have the version 3.3.0 I don't know if there is any use of it. I expect this kind of graph but i never saw it with the weighted circle. – louis devresse Jun 07 '20 at 08:04
  • Oh i'm on Windows 10 btw ! – louis devresse Jun 07 '20 at 08:55
0

Ok apparently the problem comes from the fact that values can't worth 0 so i need to add a small value to them or to remove them.