【发布时间】:2020-11-23 15:54:36
【问题描述】:
使用 R,我创建了一个图形对象并能够生成一个子图 (make_ego_graph)。 sub_graph 已成功创建,但我无法绘制此图。
我已附上以下代码:
library(igraph)
file <-data.frame(
"source" = c(
"John",
"John",
"Tim",
"Tim",
"Alex",
"Andrew",
"Andrew",
"Andrew",
"Oliver",
"Oliver",
"Oliver",
"Matt",
"Steven",
"Steven",
"Steven",
"Matt",
"Charles",
"Charles",
"Charles",
"Sean",
"Ted",
"Ryan",
"Ryan",
"Ryan",
"Ted",
"Phil",
"Phil",
"Phil",
"Sam",
"Toby",
"Toby",
"Donald",
"Donald",
"Donald",
"Mitch",
"Mitch",
"Mitch"),
"target" = c("Sam",
"Tim",
"Alex",
"Matt",
"Andrew",
"Sean",
"Peter",
"Ben",
"Kevin",
"Thomas",
"Dave",
"Steven",
"Kenny",
"Derek",
"CJ",
"Charles",
"Ivan",
"Kyle",
"Andrew",
"Ted",
"Ryan",
"Daniel",
"Chris",
"Scott",
"Phil",
"Henry",
"George",
"Paul",
"Toby",
"Donald",
"Mitch",
"Jack",
"Luke",
"Myles",
"Elliot",
"Harvey",
"Owen")
)
从这里,我创建图表:
# create graph
graph <- graph.data.frame(file, directed=F)
graph <- simplify(graph)
plot(graph)
现在,我正在尝试绘制子图:
#create subgraph
ego = make_ego_graph(graph, "John", order = 3)
plot(ego)
Error in xy.coords(x, y, xlabel, ylabel, log) :
'x' is a list, but does not have components 'x' and 'y'
谁能告诉我我做错了什么?
谢谢
【问题讨论】:
标签: r plot graph data-visualization