Network of Twitter follower ties between 339 French Members of Parliament. Data assembled in May 2013 with the help of Jonathan Chibois and Benjamin Ooghe-Tabanou from Regards Citoyens.
The following code will create an object of class network
from the two data files:
require(network)
# node information
v = read.csv("nodes.tsv", sep = "\t")
names(v) = c("sex", "first_name", "last_name", "group", "constituency",
"constituency_number", "committee", "screen_name")
# recode gender
v$sex = ifelse(v$sex == "M.", "M", "F")
# edge list
e = read.csv("network.tsv", sep = "\t")
names(e) = c("from", "to")
# network object
twitter = network(e, directed = TRUE)
# create vertex attributes
x = data.frame(screen_name = network.vertex.names(twitter))
for (i in names(v)) {
y = merge(x, v, by = "screen_name", sort = FALSE)[, i ]
set.vertex.attribute(twitter, i, as.character(y))
}
twitter
And here is some more code to create a vector of colors for the parliamentary groups:
# parliamentary group colours
colors = RColorBrewer::brewer.pal(9, "Set1")[ c(3, 1, 9, 6, 8, 5, 2) ]
names(colors) = sort(unique(twitter %v% "group"))
colors
See this blog post (in French) for more details, and this repository for similar data.