[英]R : Plotting a Graph - 'x' is a list, but does not have components 'x' and 'y'
Using R, I created a graph object and was able to produce a sub graph (make_ego_graph).使用 R,我创建了一个图形对象,并能够生成一个子图形 (make_ego_graph)。 The sub_graph has been successfully created, however I am not able to plot this graph.
sub_graph 已成功创建,但是我无法绘制此图。
I have attached the code below:我附上了下面的代码:
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")
)
From here, I create the graph:从这里,我创建了图表:
# create graph
graph <- graph.data.frame(file, directed=F)
graph <- simplify(graph)
plot(graph)
Now, I am trying to plot the subgraph:现在,我正在尝试绘制子图:
#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'
Can someone please tell me what I am doing wrong?有人可以告诉我我做错了什么吗?
Thanks谢谢
i figured it out:我想到了:
ego = make_ego_graph(graph, "John", order = 3)
a = ego[[1]]
plot(a)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.