Question

I'm using R for Social Network Analysis, trying out the packages SNA, Network, and iGraph.

My data is a data.frame structured as... d <-

Source  Target  Weight  Label
1       2       0.5     "Fred"
1       3       0.7     "Fred"
2       3       0.9     "Bill"
3       1       1.0     "Allen"

(I also have a version that is just (a) source, target, and weight, and a separate file (b) providing a correspondence between Source IDs and Label values, ie, the names of the sources, where a <-

Source  Target  Weight
1       2       0.5   
1       3       0.7   
2       3       0.9   
3       1       1.0   

labels1 <-

Source  Label
1       "Fred"
2       "Bill"
3       "Allen"

labels2 <-

Source  Label
1       "TrueName1"
2       "TrueName2"
3       "TrueName3"

)

I'm working with an Anonymized social network, so I'd like to be able to change the Name labels easily between replottings---ie using label set 1 or label set 2, where the edges are the same, but the node name correspondence between sourceID and Label Name changes.

However, when trying to use any of these packages, it seems I would have to convert the values in both source and target to be equal to the labels. Is there any easy way to append labels as a correspondence to source?

So long as I have the Label column, things like network(d) and graph.data.frame(d, directed=TRUE) won't work. Once I drop this category, it will, but my graphs have numeric labels.

What I'd like to be able to do is something like this:

plot(a, labels=NA) 
plot(a, labels=labels1) 

and

plot(a, labels=labels2) 

to move between numeric, anonymized, and non-anonymized labels on the graph.

Was it helpful?

Solution

For igraph try plot(a, vertex.label=NA).

http://igraph.sourceforge.net/doc/R/plot.common.html or ?igraph.plotting has more help on plotting.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top