0

I have two files: 1. A graph mL which has been constructed of a public transport network with nodes representing stops/stations and edges representing connections between nodes with a corresponding travel time. The nodes have an id to represent the name of their stations. 2. A csv of nodes with id, lat/long coordinates and LSOA code

I need to join the lat/long coordinates and LSOA code to the existing graphml based on the node id and not sure how to do this. I'm using igraph and R to do this.

I also then want to subset the graphml based on only selecting out the part of the network relevant to the london area. I have also a subset of London nodes to do this.

Any help would be appreciated as I'm very new to R.

Below is the code I have tried so far:

g_L<-read_graph("graph_bustuberail_london_500m.graphml",format="graphml") #import gml
file_nodes <- "graph_bustuberail_london_kdtree_nodes.csv" #import csv of nodes
mergedSegments=merge(g_L,file_nodes,by.x="id",by.y="id")

This is the error message I get:

Error in as.data.frame.default(x) : 

cannot coerce class ""igraph"" to a data.frame

  • 1
    Please [see here](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) on how to post an R question that is easy for folks to answer. That includes a representative sample of your data and code you've already written – camille Jun 24 '18 at 13:16
  • 1
    You can't use `merge` on a graph object, you want the function `set.vertex.attribute()` – Esther Jun 24 '18 at 14:17
  • Hi thanks for responding Esther. I have an id column in both g_L and file_nodes and want to add an attribute "X" "Y" and "LSOAcode" to g_L matched on id. How would I add this into the set.vertex.attribute() function? – Michael Montgomery Jun 24 '18 at 15:27

0 Answers0