-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdata.R
133 lines (124 loc) · 4.93 KB
/
data.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# Create graph objects for affiliation network data sets
# Setup
library(devtools) # for install_github()
library(igraph) # for functions
library(latentnet) # for Davis data
#install_github("corybrunson/scottish.capital")
library(scottish.capital)
# http://bioconductor.wustl.edu/data/experiment/html/SNAData.html
#source("http://bioconductor.org/biocLite.R")
#biocLite("SNAData", ask = FALSE)
library(SNAData)
# Davis Southern Women
data(davis)
women_group <- graph_from_incidence_matrix(davis)
V(women_group)$type <- !(substr(V(women_group)$name, 2, 2) %in% LETTERS)
# Fix the names
V(women_group)$name[which(V(women_group)$name == "MYRNA")] <- "MYRA"
V(women_group)$name[!V(women_group)$type] <- paste(
substr(V(women_group)$name[V(women_group)$type == 0], 1, 1),
tolower(substr(V(women_group)$name[V(women_group)$type == 0], 2,
nchar(V(women_group)$name[V(women_group)$type == 0]))),
sep = "")
V(women_group)$name[V(women_group)$type] <- c(
"6/27", "3/2", "4/12", "9/26", "2/25", "5/19", "3/15",
"9/16", "4/8", "6/10", "2/23", "4/7", "11/21", "8/3"
)
# Assign times to be days of the single calendar year
V(women_group)$time[V(women_group)$type] <- as.numeric(
as.Date(paste0("1933/", V(women_group)$name[V(women_group)$type])) -
as.Date("1932/12/31")
)
# Put the events in chronological order
women_group <- permute(women_group, c(
1:actor_count(women_group),
actor_count(women_group) +
order(order(V(women_group)[V(women_group)$type == TRUE]$time)))
)
# "Deep South" > "Social Cliques in Colored Society" > Fig. 11: Clique A
# Read data directly into bipartite incidence matrix
women_clique <- graph_from_incidence_matrix(as.matrix(read.csv(
"DGG_Clique_A.csv",
row.names = 1)))
# Scott and Hughes, *The Anatomy of Scottish Capital*
# https://github.com/corybrunson/scottish.capital
data(scottish.capital)
scotland1920s <- permute(scottish.capital[[2]],
order(order(V(scottish.capital[[2]])$type)))
# Galaskiewicz, "Social organization of an urban grants economy"
library(SNAData)
data(CEOclubsAM)
minneapolis1970s <- graph_from_incidence_matrix(CEOclubsAM)
# Barnes-Burkett corporate board affiliations
# Read data directly into bipartite incidence matrix
chicago1960s <- graph_from_incidence_matrix(as.matrix(read.csv(
"Barnes-Burkett-Table1.csv", row.names = 1)))
# Noordin Top Terrorist Network Data
# http://www.thearda.com/Archive/Files/Descriptions/TERRNET.asp
# SPSS data were (a) copied into a csv and (b) their names put into a string
# Read data into a data frame
data <- read.csv("Noordin-network.csv", header = FALSE)
rownames(data) <- data[, 1]
data <- data[, 2:dim(data)[2]]
colnames(data) <- c(
paste("organ", 1:32, sep = ""),
paste("school", 1:25, sep = ""),
paste("class", 1:79, sep = ""),
paste("commun", 1:79, sep = ""),
paste("kin", 1:79, sep = ""),
paste("train", 1:16, sep = ""),
paste("employ", 1:10, sep = ""),
paste("operat", 1:14, sep = ""),
paste("friend", 1:79, sep = ""),
paste("relig", 1:8, sep = ""),
paste("soul", 1:79, sep = ""),
paste("place", 1:35, sep = ""),
paste("provide", 1:4, sep = ""),
paste("meet", 1:20, sep = ""),
"educ", "contact", "military", "nation", "status", "role", "group",
"noordin")
# Restrict to the 32 organizations
data1 <- data[, grep("meet", colnames(data))]
data1 <- data1[rowSums(data1) > 0, ]
nmt_meetings <- graph_from_incidence_matrix(as.matrix(data1))
data2 <- data[, grep("organ", colnames(data))]
data2 <- data2[rowSums(data2) > 0, ]
nmt_organizations <- graph_from_incidence_matrix(as.matrix(data2))
# Fischer-Han Whig groups
# http://www.sscnet.ucla.edu/polisci/faculty/chwe/ps269/han.pdf
# https://github.com/kjhealy/revere
# Read data into a data frame
data <- read.csv("PaulRevereAppD.csv", row.names = 1)
# Remove non-group affiliations (Tea Party and London Enemies)
# and any participants who don't feature elsewhere
data <- data[!(names(data) %in% c("TeaParty", "LondonEnemies"))]
data <- data[rowSums(data) > 0, ]
whigs <- graph_from_incidence_matrix(as.matrix(data))
V(whigs)$name[V(whigs)$type == 0] <- sapply(
V(whigs)$name[V(whigs)$type == 0], function(name) {
paste(rev(strsplit(name, split = ".", fixed = TRUE)[[1]]),
collapse = " ")
})
# Save graphs to package data folder (with comments as to why)
if (file.exists("../data")) {
for(name in c(
# widely used; dynamic; triad closure example
"women_group",
# triad census example
"women_clique",
# multiple components; interlocking directorates
"scotland1920s",
# widely used, triad closure example; interlocking directorates
"minneapolis1970s",
# actor and event nodes example; interlocking directorates
"chicago1960s",
# partial; subversive groups
"nmt_meetings",
# partial; subversive groups
"nmt_organizations",
# high actor-event ratio; subversive groups
"whigs"
)) {
save(list = name, file = paste0("../data/", name, ".rda"))
}
} else warning("Directory 'data' is not where it should be.")