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 = 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

你可能感兴趣的:(软件安装经验及报错集锦,css,html5,前端)