报错代码:
ggraph(g, "manual", x = V(g)$x, y = V(g)$y) +
geom_edge_link0() +
geom_scatterpie(
cols = c("A", "B", "C"),
data = as_data_frame(g, "vertices"), #这一行
colour = NA,
pie_scale = 2
) +
coord_fixed() +
theme_graph() +
theme(legend.position = "bottom")
报错信息:
Error in as.data.frame.default(value, stringsAsFactors = FALSE) :
cannot coerce class ‘"igraph"’ to a data.frame
解决方案:
ggraph(g, "manual", x = V(g)$x, y = V(g)$y) +
geom_edge_link0() +
geom_scatterpie(
cols = c("A", "B", "C"),
data = igraph::as_data_frame(g, "vertices"), #添加igraph::
colour = NA,
pie_scale = 2
) +
coord_fixed() +
theme_graph() +
theme(legend.position = "bottom")
参考链接:https://lists.nongnu.org/archive/html/igraph-help/2018-02/msg00019.html