简体   繁体   English

R:绘制图形 - 'x' 是一个列表,但没有组件 'x' 和 'y'

[英]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.

相关问题 (R) 绘制文本分析的结果:“x”是一个列表,但没有组件“x”和“y” - (R) Plotting the Results of Text Analysis: 'x' is a list, but does not have components 'x' and 'y' &#39;x&#39; 是一个列表,但在 R 的无监督分类中没有组件 &#39;x&#39; 和 &#39;y&#39; - 'x' is a list, but does not have components 'x' and 'y' in unsupervised classification on R 'x'是一个列表,但没有组件'x'和'y' - 'x' is a list, but does not have components 'x' and 'y' R:xy.coords 中的错误(x,y,xlabel,ylabel,log):“x”是一个列表,但没有组件“x”和“y” - R: Error in xy.coords(x, y, xlabel, ylabel, log) : 'x' is a list, but does not have components 'x' and 'y' “x”是一个列表,但没有组件“x”和“y”(预测) - 'x' is a list, but does not have components 'x' and 'y' (Forecasting) xy.coords(x,y,xlabel,ylabel,log)中的错误:“ x”是一个列表,但没有组件“ x”和“ y” - Error in xy.coords(x, y, xlabel, ylabel, log) : 'x' is a list, but does not have components 'x' and 'y' 情节子图错误:xy.coords(x, y) 中的错误:&#39;x&#39; 是一个列表,但没有组件 &#39;x&#39; 和 &#39;y&#39; - Error with plotly subplot: Error in xy.coords(x, y) : 'x' is a list, but does not have components 'x' and 'y' r中的绘图错误:“ x”和“ y”的长度不同 - Plotting error in r: 'x' and 'y' lengths differ R:使用具有通用XY绘图功能的cm单位定位图形元素 - R: Positioning graph elements using cm units with generic X-Y Plotting functions 在 R 中绘制带有反转 x 轴的折线图 - Plotting a line graph in R with a reversed x axis
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM