R:igraph,graph.data.frame错误“在边缘数据列表中未列出边缘列表中的某些顶点名称". [英] R: igraph, graph.data.frame error "Some vertex names in edge list are not listed in vertex data frame"

查看:627
本文介绍了R:igraph,graph.data.frame错误“在边缘数据列表中未列出边缘列表中的某些顶点名称".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将属性分配给网络中的顶点.我正在使用的代码是:

I am attempting to assign attributes to the vertices in my network. The code I am using is:

g2 <- graph.data.frame(edgelist2014, vertices=nodelabels2014, directed=FALSE)

其中edgelist2014是具有514,000多个观察值的边缘列表,其格式为:

where edgelist2014 is an edgelist with 514,000+ observations in this format:

fromRespondent  toRespondent   weight
1                2             6
1                3             4
...              ...           ...    
1014             1015          7

nodelabels2014是一个数据帧,其中第一列是fromRespondent,并列出1-1015,后跟14列属性数据.我也尝试过使用1-1014.

and nodelabels2014 is a data frame where the first column is fromRespondent and lists 1 - 1015 followed by 14 columns of attribute data. I have also tried this with 1 - 1014.

我以多种不同的方式运行代码,并不断收到错误消息:

I run the code in multiple different ways and keep getting the error:

Some vertex names in edge list are not listed in vertex data frame. 

我知道所有观察值都匹配,因为我在Stata中运行了合并功能,并且每个观察值都从edgelist2014nodelabels2014进行了匹配.请让我知道我在做什么错.

I know that all the observations match because I ran a merge function in Stata and every observation was matched from edgelist2014 and nodelabels2014. Please let me know what I am doing wrong.

推荐答案

我已经遇到了这个问题,并通过提出以下建议解决了该问题:

I already had this problem and solved it by developing the following suggestions:

最初,尝试分别在网络的传出和传入变量中插入非数字字符,即所谓的"fromRespondent".和"toRespondent".插入s01,s02,s03,...,而不是1、2、3,...

Initially, try to insert non-numeric characters in your network's outgoing and incoming variables, respectively, what you call "fromRespondent" and "toRespondent". Insert s01, s02, s03, ... instead of 1, 2, 3, ...

如果错误仍然存​​在,请检查数据集"edgelist2014"是否正确.和"nodelabels2014"同意.例如,查看"nodelabels2014".精确地将所有相应的顶点作为在"edgelist2014"中形成的边缘.

If the error persists, check that your data sets "edgelist2014" and "nodelabels2014" are in agreement. For example, look at "nodelabels2014" for exactly all the corresponding vertices as edges formed in "edgelist2014".

由于您的"edgelist2014"数据集中有大约514,000个示例,对于"fromRespondent"和"toRespondent"列,如果缺少的话,以及是否存在"nodelabels2014"中的这些元素中的每一个?数据集.

Since your "edgelist2014" dataset have about 514,000 examples, you will be more successful you implement the verification, for the "fromRespondent" and "toRespondent" columns, if that something that was missingand if exist each of these elements in "nodelabels2014" dataset.

这篇关于R:igraph,graph.data.frame错误“在边缘数据列表中未列出边缘列表中的某些顶点名称".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆