Facetting ggraph by nodes

I've tried tweaking the example here to facet on nodes instead of edges. But I'm getting the error:

Error in Ops.factor(self$layout$PANEL, i) : 
  level sets of factors are different

I'm sure I'm missing something obvious here?


# Create graph of highschool friendships
graph <- as_tbl_graph(highschool) %>% 
  mutate(Popularity = centrality_degree(mode = 'in'))

# plot using ggraph
ggraph(graph, layout = 'kk') + 
  geom_edge_fan(aes(alpha = stat(index)), show.legend = FALSE) + 
  geom_node_point(aes(size = Popularity)) + 
  facet_nodes(~Popularity) +
  theme_graph(foreground = 'steelblue', fg_text_colour = 'white')

So I've found this documentation which shows how to mutate popularity so it can be faceted. Although I'm not sure why that works. Surely the original popularity variable was OK to facet on?

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.