igraph-help
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[igraph] Accessing names of vertices in R


From: Eric Sun
Subject: [igraph] Accessing names of vertices in R
Date: Mon, 25 Aug 2008 11:49:50 -0700
User-agent: Microsoft-Entourage/12.10.0.080409

Hi,

I’m using the igraph R interface, and would like to get a data frame of my vertex names.

I can get the names to display properly with V():

> V(graph)
Vertex sequence:
 [1] "1209361284" "1336950007" "557545883"  "687521888"  "542248067"  "551748864"  "562264620"  "1515360054" "567418719"  "1270302894"
[11] "1341660709" "720760863"  "710772149"  "797316574"  "577749289"  "1072783645" "596842471"  "1231004904" "1313210126" "593548471"


I want to do further computation with these names (i.e. merge), so it would be helpful to have these names in a data frame.
However, I can’t do that.

> data.frame(V(graph))
Error in as.data.frame.default(x[[i]], optional = TRUE) :
  cannot coerce class "igraph.vs" into a data.frame

Nor can I use an iterator, since it doesn’t display the names:

> for (v in V(graph)) {print(v)}
[1] 0
[1] 1
[1] 2
[1] 3
[1] 4
[1] 5
[1] 6
[1] 7
[1] 8
...
Any ideas?

Thanks very much!
-Eric

reply via email to

[Prev in Thread] Current Thread [Next in Thread]