Hi,
I'm having problems using vertex/leaf weights - always returning the error "Weight must be numeric".
Setting up a graph using igraph:
library(ggraph)
library(igraph)
edges <- flare$edges
vertices <- flare$vertices
mygraph <- graph_from_data_frame(edges, vertices=vertices)
The data type of vertices$size is numeric:
> is.numeric(vertices$size)
[1] TRUE
However, attempting to plot the graph using ggraph reports that size is not numeric:
> ggraph(mygraph, layout = 'circlepack', weight = 'size')
Error in tree_to_hierarchy(graph, direction, sort.by, weight) :
Weight must be numeric
Is this an issue or am I just going about this the wrong way? I'm using R 3.4.4 in the Ubuntu linux subsystem for Windows 10
Maybe unquote 'size'? (weight = size). Works for me, sometimes..
Ah, brilliant! That worked, any idea why though?
Many inputs to layouts are tidy evaluated and must given as unquoted expressions. This is given in the documentation
Just ran into this problem today, too. Think this is because we are following the snippet in holtzy's very nice R-graph-gallery (https://www.r-graph-gallery.com/313-basic-circle-packing-with-several-levels.html).
Just opened a pull request against the r-graph-gallery
repo, so hopefully no one else will hit this one.
Most helpful comment
Maybe unquote 'size'? (weight = size). Works for me, sometimes..