-3

I've built a network and I want to load it into Gephi. The attribute labels are id(v) and weight(e), but Gephi will overwrite the "id" label, so I want to change it to "label". I've tried the following:

names(cityw)["id"] <- "label"
names(V(cityw)$id) <- "label"
names(cityw$id) <- label
names(V(cityw)$id) <- label`
hrbrmstr
  • 77,368
  • 11
  • 139
  • 205
user4100980
  • 127
  • 1
  • 1
  • 13
  • 1
    Without an object or a much better description, this a guessing game. – IRTFM Oct 11 '15 at 02:38
  • 1
    Post some code (starting with library calls to all packages needed) that creates an object that resembles your R-object. Or post the output of `dput(object)`. Or maybe even posting `str(object)` would be sufficient. Then say what you want changed. It might be simple, but ... who knows at this point? (We cannot read your mind or hack into your console session.) – IRTFM Oct 11 '15 at 03:01
  • All I want to know is if, IN GENERAL, it's possible to change the name of an attribute in a network. If you have ever dealt with any network in R, the summary tells you the same information - names of attributes and whether they are edges or vertices. My question has nothing to do with the data at all. – user4100980 Oct 11 '15 at 03:08
  • 1
    "My question has nothing to do with the data at all"? Attributes are parts of data-objects. – IRTFM Oct 11 '15 at 03:12
  • 2
    rather than changing the name of an attribute you could copy it to a new one (ag `V(g)$newname <- V(g)$name`, and then remove it `g <- remove.vertex.attribute(g, "name")`. – user20650 Oct 11 '15 at 05:24
  • 1
    But it would be definitely helpful if you could add an example to your question - say from the examples from the bottom of `?graph_from_data_frame` - and show your expected outcome. – user20650 Oct 11 '15 at 05:26
  • 1
    Thanks, adding the new attribute and then using `remove.vertex.attribute` was exactly what I needed. – user4100980 Oct 11 '15 at 12:06

1 Answers1

1

I don't see what you are trying to accomplish, too. But maybe you want to try your export like this:

library(igraph)
g <- ba.game(10) # sample graph

V(g)$label <- LETTERS[1:10] # set vertex labels to A-J

E(g)$foo <- sample(1:5, 10, T) # set custom edge label... 
names(edge_attr(g))[which(names(edge_attr(g)) == "foo")] <- "weight" # ... and rename it to weight

write_graph(g, tf <- tempfile(fileext = ".graphml"), "graphml") # export graph
system(paste('"C:\\Program Files (x86)\\Gephi-0.8.2\\bin\\gephi.exe"', tf), wait = FALSE) # adjust path here
lukeA
  • 53,097
  • 5
  • 97
  • 100