I have an igraph where each vertex has both a vertex ID and a name. I want the vertices to still be identified by their vertex ID's, but to be labeled by their names. It seems like when adding labels to vertices through V(g)$label <- names, the names have to be in order. Is there a way to maybe put in a named vector or dataframe that names the vertices based on their IDs?
names <- c('A','B','C,','D')
from <- c(113,115,112,114,113)
to <- c(112,112,115,113,114)
structure <- data.frame("from" = from, "to" = to)
g <- graph.data.frame(structure)
V(g)$label <- names
I want to be able to specify which vertex is A, which is B, etc - i.e. 115 is A, 112 is B...