Andrew Hargrove
Andrew Hargrove

Reputation: 21

R: igraph, graph.data.frame error "Some vertex names in edge list are not listed in vertex 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)

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

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

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. 

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.

Upvotes: 2

Views: 16248

Answers (2)

Bravedo
Bravedo

Reputation: 1

I have the same question which is not seemingly working for non-numeric data. I want to produce an igraph showing linkages of actors.

nodes <- read.csv("D1-NODES.csv", header=T, as.is=T)
links <- read.csv("D1-EDGES.csv", header=T, as.is=T)

Data D1-EDGES.csv D1-NODES.csv

# Producing the igraph

net <- graph_from_data_frame(d=links, vertices=nodes, directed=T)
#create a layout for plot
l <- layout_nicely(net2)
p1 <- plot(net2, edge.arrow.size= 0.5, edge.curved= 0.2, vertex.color=nodes$Inter.type, rescale=5, frame= T,vertex.label.cex=1.4, vertex.size=20, vertex.label.color="black",edge.lty= 2, vertex.frame.color= "gray", layout=l )

I get this error message:

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

Upvotes: 0

user14644863
user14644863

Reputation: 1

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

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, ...

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".

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.

Upvotes: -1

Related Questions