igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] Accessing names of vertices in R


From: Csardi Gabor
Subject: Re: [igraph] Accessing names of vertices in R
Date: Mon, 25 Aug 2008 20:55:03 +0200
User-agent: Mutt/1.5.9i

Eric,

vertex names are just the 'name' vertex attribute, so do 

data.frame(name = V(g)$name)

G.

On Mon, Aug 25, 2008 at 11:49:50AM -0700, Eric Sun wrote:
> 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

> _______________________________________________
> igraph-help mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/igraph-help


-- 
Csardi Gabor <address@hidden>    MTA RMKI, ELTE TTK




reply via email to

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