[R] how to get degree according to the name of the node?
dieter.menne at menne-biomed.de
Tue Dec 30 10:34:31 CET 2008
Weijia You <weijiawx <at> gmail.com> writes:
> I have two networks for the same group of the users.
> I want to compare individual's degree in different networks.
> But how could I get the degrere of the nodes according to its name?
> When I use degree(g1), I could only get a vector of the degree of each node.
> But when I turn to g2, I don't know whose degree it is so I can't match it
> with the degree(g2).
> Now I'm trying to make the users appearing in the edgelist in the same
> for example:
> in g1 input file
> A B 1
> C D 2
> C B 3
> in g2 input file
> A B 0
> C D 12
> C B 0
> If I make the two input file like this, will it help? I mean the degree
> vector will be exactly the same in the two graph?
This probably refers to the degree in the sna package. Assuming the
example below, try to reformulate you problem (but please keep the code
self-running, at least up the the point where the problem is).
g1 <- degree(rgraph(10))
g2 <- degree(rgraph(10))
g2 == g1 # is it this you need?
More information about the R-help