This website is a replication package for the paper “Twitter and divides in the Dutch Parliament: Social and Political Segregation in the following, @-mentions and retweets networks” by Tolsma and Spierings ((submitted)).
It contains R code to replicate all Tables/Figures/Appendix in the manuscript.
To copy the code click the button in the upper right corner of the code-chunks.
Use the top menu to navigate to the section of interest.
The source code of this website can be found on Github
Questions can be addressed to Jochem Tolsma.
# install if necessary
if (!require("tidyverse", character.only = TRUE)) {
install.packages("tidyverse", dependencies = TRUE)
}
if (!require("dplyr", character.only = TRUE)) {
install.packages("dplyr", dependencies = TRUE)
}
if (!require("foreign", character.only = TRUE)) {
install.packages("foreign", dependencies = TRUE)
}
if (!require("igraph", character.only = TRUE)) {
install.packages("igraph", dependencies = TRUE)
}
if (!require("knitr", character.only = TRUE)) {
install.packages("knitr", dependencies = TRUE)
}
if (!require("kableExtra", character.only = TRUE)) {
install.packages("kableExtra", dependencies = TRUE)
}
if (!require("RSiena", character.only = TRUE)) {
install.packages("RSiena", dependencies = TRUE)
}
if (!require("netseg", character.only = TRUE)) {
install.packages("netseg", dependencies = TRUE)
}
# load packages.
library(tidyverse)
library(dplyr)
library(foreign)
library(igraph)
library(knitr)
library(kableExtra)
library(RSiena)
library(netseg)
Define custom functions to calculate network-segregation:
fdensity <- function(x) {
# x is your nomination network should be relationship, divided by all possible off diagonal
# ties. make sure diagonal cells are NA
diag(x) <- NA
x[x == 10] <- NA
sum(x == 1, na.rm = T)/(sum(x == 1 | x == 0, na.rm = T))
}
fdensityintra <- function(x, A) {
# A is matrix indicating whether nodes constituting dyad have same characteristics
diag(x) <- NA
x[x == 10] <- NA
diag(A) <- NA
sum(x == 1 & A == 1, na.rm = T)/(sum((x == 1 | x == 0) & A == 1, na.rm = T))
}
fdensityinter <- function(x, A) {
# A is matrix indicating whether nodes constituting dyad have same characteristics
diag(x) <- NA
x[x == 10] <- NA
diag(A) <- NA
sum(x == 1 & A != 1, na.rm = T)/(sum((x == 1 | x == 0) & A != 1, na.rm = T))
}
fhomomat <- function(x) {
xmat <- matrix(x, nrow = length(x), ncol = length(x))
xmatt <- t(xmat)
xhomo <- xmat == xmatt
return(xhomo)
}
fndyads <- function(x) {
diag(x) <- NA
x[x == 10] <- NA
(sum((x == 1 | x == 0), na.rm = T))
}
fndyads2 <- function(x, A) {
diag(x) <- NA
x[x == 10] <- NA
diag(A) <- NA
(sum((x == 1 | x == 0) & A == 1, na.rm = T))
}
fscolnet <- function(network, ccovar) {
# Calculate coleman on network level:
# https://reader.elsevier.com/reader/sd/pii/S0378873314000239?token=A42F99FF6E2B750436DD2CB0DB7B1F41BDEC16052A45683C02644DAF88215A3379636B2AA197B65941D6373E9E2EE413
fhomomat <- function(x) {
xmat <- matrix(x, nrow = length(x), ncol = length(x))
xmatt <- t(xmat)
xhomo <- xmat == xmatt
return(xhomo)
}
fsumintra <- function(x, A) {
# A is matrix indicating whether nodes constituting dyad have same characteristics
diag(x) <- NA
x[x == 10] <- NA
diag(A) <- NA
sum(x == 1 & A == 1, na.rm = T)
}
# expecation w*=sum_g sum_i (ni((ng-1)/(N-1)))
network[network == 10] <- NA
ni <- rowSums(network, na.rm = T)
ng <- NA
for (i in 1:length(ccovar)) {
ng[i] <- table(ccovar)[rownames(table(ccovar)) == ccovar[i]]
}
N <- length(ccovar)
wexp <- sum(ni * ((ng - 1)/(N - 1)), na.rm = T)
# wgg1 how many intragroup ties
w <- fsumintra(network, fhomomat(ccovar))
Scol_net <- ifelse(w >= wexp, (w - wexp)/(sum(ni, na.rm = T) - wexp), (w - wexp)/wexp)
return(Scol_net)
}
Data objects:
# STAP 1: read in data
key <- read.spss("data-processed\\key moederbestand 20171114.sav", use.value.labels = T, to.data.frame = T)
load("data-processed\\twitter_20190919.RData")
# str(twitter_20190919,1)
keyf <- twitter_20190919[[1]]
mydata <- twitter_20190919[[2]]
seats <- twitter_20190919[[3]]
# select all MPs (we need to filter the correct EGOhandle)
data_mp <- key %>%
filter(Elected20170315 == "yes, verkozen" & !(EGOhandle %in% c(10401, 10403, 13102, 15102, 106101,
41400))) %>%
select("Naam", "Partij", "Geslacht", "GebJaar", "EthMinZ", "PlekLijst", "Kamerlid20161123", "ZetelSegment20170315",
"ZetelRij20170315", "ZetelKolom20170315")
# not necessary: 'Twitterhandle' 'Elected20170315'
seats$ZetelSegment20170315 <- seats$segments
seats$ZetelRij20170315 <- seats$rows
seats$ZetelKolom20170315 <- seats$columns
data_mp <- inner_join(data_mp, seats) %>%
select("Naam", "Partij", "Geslacht", "GebJaar", "EthMinZ", "PlekLijst", "Kamerlid20161123", "ZetelSegment20170315",
"ZetelRij20170315", "ZetelKolom20170315", "X", "Y")
colnames(data_mp) <- c("Name", "Party", "Sex", "Birth Year", "Visible Minority", "List Position", "Incumbency status",
"Seating Segment", "Seating Row", "Seating Column", "X-coord.", "Y-coord")
data_mp$Sex <- as.character(data_mp$Sex)
data_mp$Sex[data_mp$Sex == "vrouw"] <- "female"
data_mp$Sex[data_mp$Sex == "man"] <- "male"
sumdat <- kbl(data_mp, booktabs = TRUE, digits = 2, caption = "Dataset summary", align = "c") %>%
kable_classic(full_width = F, html_font = "Cambria") %>%
kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"))
scroll_box(sumdat, width = "100%", height = "500px")
Name | Party | Sex | Birth Year | Visible Minority | List Position | Incumbency status | Seating Segment | Seating Row | Seating Column | X-coord. | Y-coord |
---|---|---|---|---|---|---|---|---|---|---|---|
Agema, Fleur | PVV | female | 1976 | 0 | 2 | 1 | 1 | 1 | 2 | 7.9 | -2.9 |
Amhaouch, Mustafa | CDA | male | 1970 | 1 | 15 | 1 | 2 | 3 | 1 | 9.5 | 1.3 |
Arib, Khadija | PvdA | female | 1960 | 1 | 2 | 1 | 6 | 6 | 3 | -16.1 | -0.8 |
|
VVD | female | 1974 | 0 | 4 | 1 | 3 | 2 | 1 | 3.9 | 3.5 |
Azmani, Malik | VVD | male | 1976 | 1 | 10 | 1 | 3 | 3 | 2 | 3.7 | 5.5 |
Beertema, Harm | PVV | male | 1952 | 0 | 10 | 1 | 1 | 4 | 1 | 13.6 | -4.5 |
Belhaj, Salima | D66 | female | 1979 | 1 | 14 | 1 | 4 | 4 | 3 | -3.3 | 7.4 |
Bergkamp, Vera | D66 | female | 1971 | 0 | 6 | 1 | 4 | 3 | 4 | -4.6 | 5.0 |
Bisschop, Roelof | SGP | male | 1956 | 0 | 3 | 1 | 3 | 4 | 3 | 3.6 | 7.4 |
Bosma, Martin | PVV | male | 1964 | 0 | 6 | 1 | 1 | 2 | 1 | 10.0 | -4.4 |
Bosman, Andre | VVD | male | 1965 | 0 | 24 | 1 | 3 | 4 | 5 | 1.2 | 7.8 |
ten Broeke, Han | VVD | male | 1969 | 0 | 9 | 1 | 3 | 2 | 2 | 2.6 | 4.0 |
Bruins Slot, Hanke | CDA | female | 1977 | 0 | 9 | 1 | 2 | 3 | 3 | 7.8 | 2.9 |
Van Dijck, Tony | PVV | male | 1963 | 0 | 8 | 1 | 1 | 3 | 3 | 11.3 | -1.9 |
Van Dijk, Jasper | SP | male | 1971 | 0 | 14 | 1 | 6 | 6 | 6 | -16.9 | -4.4 |
Dijkgraaf, Elbert | SGP | male | 1970 | 0 | 2 | 1 | 3 | 4 | 2 | 4.7 | 7.0 |
Dijkstra, Pia | D66 | female | 1954 | 0 | 4 | 1 | 4 | 2 | 1 | -1.1 | 4.2 |
Dijkstra, Remco | VVD | male | 1972 | 0 | 27 | 1 | 3 | 5 | 3 | 4.0 | 9.1 |
Dik-Faber, Carla | CU | female | 1971 | 0 | 4 | 1 | 2 | 5 | 4 | 9.9 | 6.1 |
Duisenberg, Pieter | VVD | male | 1967 | 0 | 15 | 1 | 4 | 5 | 1 | -1.2 | 9.6 |
Fritsma, Sietse | PVV | male | 1972 | 0 | 5 | 1 | 1 | 3 | 1 | 11.8 | -4.5 |
Geurts, Jaco | CDA | male | 1970 | 0 | 10 | 1 | 1 | 4 | 4 | 12.8 | -1.0 |
De Graaf, Machiel | PVV | male | 1969 | 0 | 11 | 1 | 1 | 4 | 2 | 13.5 | -3.2 |
Grashoff, Rik | GroenLinks | male | 1961 | 0 | 5 | 1 | 5 | 3 | 1 | -6.8 | 3.8 |
Graus, Dion | PVV | male | 1967 | 0 | 12 | 1 | 1 | 4 | 3 | 13.2 | -2.1 |
Van Haersma Buma, Sybrand | CDA | male | 1965 | 0 | 1 | 1 | 2 | 1 | 2 | 5.3 | 0.5 |
Harbers, Mark | VVD | male | 1969 | 0 | 8 | 1 | 3 | 2 | 3 | 1.3 | 4.2 |
Heerma, Pieter | CDA | male | 1977 | 0 | 7 | 1 | 2 | 2 | 1 | 7.9 | 0.3 |
Helder, Lilian | PVV | female | 1973 | 0 | 9 | 1 | 1 | 3 | 4 | 10.8 | -0.9 |
Van Helvert, Martijn | CDA | male | 1978 | 0 | 16 | 1 | 1 | 4 | 5 | 12.5 | 0.0 |
Keijzer, Mona | CDA | female | 1968 | 0 | 2 | 1 | 2 | 1 | 1 | 6.4 | -0.4 |
Klaver, jesse | GroenLinks | male | 1986 | 1 | 1 | 1 | 5 | 1 | 1 | -5.1 | 0.5 |
Knops, Raymond | CDA | male | 1971 | 0 | 6 | 1 | 2 | 2 | 2 | 7.1 | 1.4 |
Kooiman, Nine | SP | female | 1980 | 0 | 12 | 1 | 6 | 6 | 4 | -16.4 | -1.9 |
Koolmees, Wouter | D66 | male | 1977 | 0 | 3 | 1 | 4 | 2 | 3 | -3.7 | 3.5 |
Krol, Henk | 50Plus | male | 1950 | 0 | 1 | 1 | 5 | 5 | 5 | -12.4 | 3.1 |
Kuiken, Attje | PvdA | female | 1977 | 0 | 6 | 1 | 6 | 3 | 2 | -11.0 | -1.9 |
Kuzu, Tunahan | DENK | male | 1981 | 1 | 1 | 1 | 5 | 6 | 2 | -10.3 | 7.5 |
Leijten, Renske | SP | female | 1979 | 0 | 2 | 1 | 6 | 1 | 2 | -8.0 | -4.3 |
Lodders, Helma | VVD | female | 1968 | 0 | 12 | 1 | 3 | 3 | 1 | 4.8 | 5.0 |
Madlener, Barry | PVV | male | 1969 | 0 | 7 | 1 | 1 | 3 | 2 | 11.6 | -3.2 |
Van Meenen, Paul | D66 | male | 1956 | 0 | 8 | 1 | 4 | 4 | 5 | -5.5 | 6.5 |
Mulder, Agnes | CDA | female | 1973 | 0 | 13 | 1 | 1 | 5 | 5 | 14.0 | 0.8 |
Nijboer, Henk | PvdA | male | 1983 | 0 | 7 | 1 | 6 | 5 | 2 | -14.3 | -0.4 |
Nijkerken-de Haan, Chantal | VVD | female | 1973 | 0 | 30 | 1 | 4 | 6 | 2 | -2.3 | 11.0 |
Van Nispen, Michiel | SP | male | 1982 | 0 | 7 | 1 | 6 | 3 | 4 | -11.5 | -4.5 |
Omtzigt, Pieter | CDA | male | 1974 | 0 | 4 | 1 | 2 | 2 | 3 | 6.1 | 2.1 |
Van Oosten, Foort | VVD | male | 1977 | 0 | 32 | 1 | 3 | 5 | 2 | 5.4 | 8.6 |
Ozturk, Selcuk | DENK | male | 1972 | 1 | 3 | 1 | 5 | 6 | 4 | -12.2 | 5.8 |
Pechtold, Alexander | D66 | male | 1965 | 0 | 1 | 1 | 4 | 1 | 2 | -2.6 | 2.1 |
Van Raak, Ronald | SP | male | 1969 | 0 | 4 | 1 | 6 | 2 | 2 | -9.5 | -3.1 |
Roemer, Emile | SP | male | 1962 | 0 | 1 | 1 | 6 | 1 | 1 | -7.7 | -2.9 |
Rog, Michel | CDA | male | 1973 | 0 | 14 | 1 | 2 | 5 | 2 | 11.8 | 4.1 |
Ronnes, Erik | CDA | male | 1967 | 0 | 17 | 1 | 2 | 6 | 1 | 14.1 | 3.8 |
De Roon, Raymond | PVV | male | 1952 | 0 | 13 | 1 | 1 | 5 | 1 | 15.4 | -4.4 |
Rutte, Arno | VVD | male | 1972 | 0 | 20 | 1 | 3 | 5 | 5 | 1.3 | 9.6 |
Schouten, Carola | CU | female | 1977 | 0 | 2 | 1 | 2 | 4 | 4 | 8.8 | 4.7 |
Segers, Gert-Jan | CU | male | 1969 | 0 | 1 | 1 | 2 | 4 | 5 | 7.9 | 5.4 |
Sjoerdsma, Sjoerd | D66 | male | 1981 | 0 | 11 | 1 | 4 | 3 | 1 | -1.0 | 6.0 |
Van der Staaij, Kees | SGP | male | 1968 | 0 | 1 | 1 | 3 | 4 | 1 | 5.7 | 6.5 |
Tellegen, Ockje | VVD | female | 1974 | 0 | 21 | 1 | 3 | 5 | 4 | 2.6 | 9.3 |
Thieme, Marianne | PvdDieren | female | 1972 | 0 | 1 | 1 | 5 | 4 | 2 | -8.6 | 4.7 |
Van Toorenburg, Madeleine | CDA | female | 1986 | 0 | 5 | 1 | 2 | 6 | 2 | 13.3 | 4.8 |
Van Veldhoven, Stientje | D66 | female | 1973 | 0 | 2 | 1 | 4 | 1 | 1 | -1.3 | 2.4 |
Verhoeven, Kees | D66 | male | 1976 | 0 | 7 | 1 | 4 | 2 | 2 | -2.4 | 4.0 |
Visser, Barbara | VVD | female | 1977 | 0 | 7 | 1 | 3 | 4 | 4 | 2.3 | 7.7 |
Voordewind, Joel | CU | male | 1965 | 0 | 3 | 1 | 2 | 5 | 5 | 8.8 | 6.8 |
Voortman, Linda | GroenLinks | female | 1979 | 0 | 4 | 1 | 5 | 2 | 2 | -6.9 | 1.4 |
De Vries, Aukje | VVD | female | 1964 | 0 | 18 | 1 | 4 | 6 | 3 | -3.6 | 10.8 |
Wassenberg, Frank | PvdDieren | male | 1966 | 0 | 4 | 0 | 5 | 5 | 2 | -9.6 | 6.1 |
Van Weyenberg, Steven | D66 | male | 1973 | 0 | 10 | 1 | 4 | 3 | 3 | -3.6 | 5.5 |
Wilders, Geert | PVV | male | 1963 | 0 | 1 | 1 | 1 | 1 | 1 | 8.2 | -4.3 |
Van t’Wout, Bas | VVD | male | 1979 | 0 | 13 | 1 | 4 | 5 | 2 | -2.4 | 9.3 |
Ziengs, Erik | VVD | male | 1960 | 0 | 23 | 1 | 4 | 4 | 1 | -1.1 | 7.8 |
Zijlstra, Halbe | VVD | male | 1969 | 0 | 3 | 1 | 3 | 1 | 2 | 1.4 | 2.4 |
Rutte, Mark | VVD | male | 1967 | 0 | 1 | 0 | 3 | 1 | 1 | 3.0 | 2.1 |
Ploumen, Lilianne | PvdA | female | 1962 | 0 | 10 | 0 | 6 | 6 | 2 | -15.7 | 0.6 |
Hennis-Plasschaert, Jeanine | VVD | female | 1973 | 0 | 2 | 0 | 3 | 3 | 4 | 1.3 | 6.0 |
Dijsselbloem, Jeroen | PvdA | male | 1966 | 0 | 3 | 0 | 6 | 4 | 2 | -12.6 | -1.0 |
Asscher, Lodewijk | PvdA | male | 1974 | 0 | 1 | 0 | 6 | 3 | 1 | -10.6 | -0.9 |
Dijksma, Sharon | PvdA | female | 1971 | 0 | 4 | 0 | 6 | 4 | 3 | -13.0 | -2.1 |
Dekker, Sander | VVD | male | 1975 | 0 | 6 | 0 | 3 | 5 | 1 | 6.5 | 8.2 |
Dijkhoff, Klaas | VVD | male | 1981 | 0 | 5 | 0 | 3 | 3 | 3 | 2.4 | 5.9 |
Thierry Baudet | FvD | male | 1983 | 0 | 1 | 0 | 1 | 6 | 6 | 15.4 | 1.6 |
Eppo Bruins | CU | male | 1969 | 0 | 5 | 1 | 2 | 5 | 3 | 10.9 | 5.1 |
LILIAN MARIJNISSEN | SP | female | 1985 | 0 | 3 | 0 | 6 | 2 | 1 | -9.0 | -1.8 |
SADET KARABULUT | SP | female | 1975 | 1 | 5 | 1 | 6 | 2 | 3 | -9.8 | -4.4 |
SANDRA BECKERMAN | SP | female | 1983 | 0 | 6 | 0 | 6 | 3 | 3 | -11.4 | -3.2 |
PETER KWINT | SP | male | 1984 | 0 | 8 | 0 | 6 | 4 | 4 | -13.2 | -3.2 |
BART VAN KENT | SP | male | 1983 | 0 | 9 | 0 | 6 | 4 | 5 | -13.3 | -4.5 |
CEM LACIN | SP | male | 1986 | 1 | 10 | 0 | 6 | 5 | 4 | -15.0 | -3.2 |
FRANK FUTSELAAR | SP | male | 1979 | 0 | 11 | 0 | 6 | 5 | 5 | -15.1 | -4.4 |
MAARTEN HIJINK | SP | male | 1983 | 0 | 13 | 0 | 6 | 6 | 5 | -16.6 | -3.2 |
Ingrid van Engelshoven | D66 | female | 1966 | 0 | 5 | 0 | 4 | 3 | 2 | -2.3 | 5.9 |
Jan Paternotte | D66 | male | 1984 | 0 | 9 | 0 | 4 | 5 | 3 | -3.7 | 9.1 |
Rob Jetten | D66 | male | 1987 | 0 | 12 | 0 | 4 | 5 | 4 | -5.1 | 8.6 |
Jessica van Eijs | D66 | female | 1981 | 0 | 13 | 0 | 4 | 4 | 4 | -4.5 | 7.0 |
Maarten Groothuizen | D66 | male | 1976 | 0 | 15 | 0 | 4 | 6 | 5 | -5.9 | 10.1 |
Rens Raemakers | D66 | male | 1991 | 0 | 17 | 0 | 4 | 6 | 4 | -4.8 | 10.5 |
Achraf Bouali | D66 | male | 1974 | 1 | 16 | 0 | 4 | 5 | 5 | -6.3 | 8.2 |
Antje Diertens | D66 | female | 1958 | 0 | 18 | 0 | 4 | 6 | 6 | -7.2 | 9.6 |
Tjeerd de Groot | D66 | male | 1968 | 0 | 19 | 0 | 5 | 6 | 1 | -9.4 | 8.3 |
René Peters | CDA | male | 1975 | 0 | 3 | 0 | 2 | 5 | 1 | 12.7 | 3.1 |
Harry van der Molen | CDA | male | 1980 | 0 | 8 | 0 | 2 | 4 | 3 | 9.6 | 4.0 |
Anne Kuik | CDA | female | 1987 | 0 | 11 | 0 | 2 | 4 | 1 | 11.1 | 2.2 |
Chris van Dam | CDA | male | 1963 | 0 | 12 | 0 | 2 | 3 | 4 | 6.8 | 3.8 |
Joba van den Berg-Jansen | CDA | female | 1958 | 0 | 18 | 0 | 2 | 3 | 2 | 8.7 | 2.2 |
Maurits von Martels | CDA | male | 1960 | 0 | 44 | 0 | 2 | 4 | 2 | 10.4 | 3.0 |
Dennis Wiersma | VVD | male | 1986 | 0 | 11 | 0 | 4 | 6 | 1 | -1.0 | 11.2 |
Bente Becker | VVD | female | 1985 | 0 | 14 | 0 | 3 | 6 | 6 | 1.3 | 11.2 |
Sophie Hermans | VVD | female | 1981 | 0 | 16 | 0 | 3 | 6 | 5 | 2.6 | 11.0 |
Anne Mulder | VVD | male | 1969 | 0 | 17 | 1 | 4 | 4 | 2 | -2.2 | 7.7 |
Dilan Yesilgöz-Zegerius | VVD | female | 1977 | 1 | 19 | 0 | 3 | 6 | 4 | 3.7 | 10.8 |
Daniel Koerhuis | VVD | male | 1981 | 0 | 22 | 0 | 3 | 6 | 3 | 5.0 | 10.5 |
Albert van den Bosch | VVD | male | 1955 | 0 | 25 | 0 | 3 | 6 | 2 | 6.3 | 10.1 |
Zohair el Yassini | VVD | male | 1979 | 1 | 26 | 0 | 3 | 6 | 1 | 7.3 | 9.6 |
Martin Wörsdörfer | VVD | male | 1972 | 0 | 28 | 0 | 2 | 6 | 6 | 9.5 | 8.3 |
Arne Weverling | VVD | male | 1974 | 0 | 29 | 0 | 2 | 6 | 5 | 10.6 | 7.5 |
Sven Koopmans | VVD | male | 1973 | 0 | 33 | 0 | 2 | 6 | 4 | 11.6 | 6.8 |
Jan Middendorp | VVD | male | 1975 | 0 | 34 | 0 | 2 | 6 | 3 | 12.5 | 5.8 |
Léonie Sazias | 50Plus | female | 1957 | 0 | 2 | 0 | 5 | 5 | 4 | -11.5 | 4.1 |
Martin van Rooijen | 50Plus | male | 1942 | 0 | 3 | 0 | 5 | 6 | 5 | -13.1 | 4.8 |
Corrie van Brenk | 50Plus | female | 1960 | 0 | 4 | 0 | 5 | 6 | 6 | -13.9 | 3.8 |
Esther Ouwehand | PvdDieren | female | 1976 | 0 | 2 | 1 | 5 | 4 | 1 | -7.7 | 5.4 |
Kathalijne Buitenweg | GroenLinks | female | 1970 | 0 | 2 | 0 | 5 | 1 | 2 | -6.1 | -0.4 |
Tom van der Lee | GroenLinks | male | 1964 | 0 | 3 | 0 | 5 | 2 | 3 | -7.7 | 0.3 |
Corinne Ellemeet | GroenLinks | female | 1976 | 0 | 7 | 0 | 5 | 3 | 3 | -8.6 | 2.2 |
Zihni Özdil | GroenLinks | male | 1981 | 1 | 8 | 0 | 5 | 3 | 4 | -9.3 | 1.3 |
Bart Snels | GroenLinks | male | 1966 | 0 | 9 | 0 | 5 | 2 | 1 | -5.9 | 2.1 |
Suzanne Kröger | GroenLinks | female | 1977 | 0 | 11 | 0 | 5 | 4 | 4 | -10.4 | 3.0 |
Bram van Oijk | GroenLinks | male | 1954 | 0 | 10 | 0 | 5 | 4 | 5 | -11.0 | 2.2 |
Nevin Özütok | GroenLinks | female | 1960 | 1 | 12 | 0 | 5 | 4 | 3 | -9.5 | 4.0 |
Lisa Westerveld | GroenLinks | female | 1981 | 0 | 14 | 0 | 6 | 5 | 1 | -13.8 | 0.8 |
Isabelle Diks | GroenLinks | female | 1965 | 0 | 19 | 0 | 6 | 6 | 1 | -15.2 | 1.6 |
Liesbeth van Tongeren | GroenLinks | female | 1958 | 0 | 6 | 1 | 5 | 3 | 2 | -7.7 | 2.9 |
Lammert van Raan | PvdDieren | male | 1962 | 0 | 3 | 0 | 5 | 5 | 1 | -8.6 | 6.8 |
Femke Merel Arissen | PvdDieren | female | 1983 | 0 | 5 | 0 | 5 | 5 | 3 | -10.7 | 5.1 |
Farid Azarkan | DENK | male | 1971 | 1 | 2 | 0 | 5 | 6 | 3 | -11.3 | 6.8 |
Gijs van Dijk | PvdA | male | 1980 | 0 | 5 | 0 | 6 | 4 | 1 | -12.2 | 0.0 |
Kirsten van den Hul | PvdA | female | 1976 | 0 | 8 | 0 | 6 | 5 | 3 | -14.6 | -1.7 |
Gerbrands, Karen | PVV | female | 1967 | 0 | 16 | 0 | 1 | 5 | 4 | 14.4 | -0.4 |
Theo Hiddema | FvD | male | 1944 | 0 | 2 | 0 | 1 | 6 | 5 | 15.9 | 0.6 |
Vicky Maeijer | PVV | female | 1986 | 0 | 3 | 0 | 1 | 2 | 3 | 9.3 | -1.8 |
Gidi Markuszower | PVV | male | 1977 | 1 | 4 | 0 | 1 | 2 | 2 | 9.8 | -3.1 |
Danai van Weerdenburg | PVV | female | 1976 | 0 | 14 | 0 | 1 | 5 | 2 | 15.2 | -3.2 |
Edgar Mulder | PVV | male | 1961 | 0 | 15 | 0 | 1 | 5 | 3 | 14.9 | -1.7 |
Léon de Jong | PVV | male | 1982 | 0 | 17 | 0 | 1 | 6 | 1 | 17.1 | -4.4 |
Gabriëlle Popken | PVV | female | 1983 | 0 | 18 | 0 | 1 | 6 | 2 | 16.9 | -3.2 |
Alexander Kops | PVV | male | 1984 | 0 | 19 | 0 | 1 | 6 | 3 | 16.7 | -1.9 |
Roy van Aalst | PVV | male | 1983 | 0 | 20 | 0 | 1 | 6 | 4 | 16.3 | -0.8 |
# select all MPs (we need to filter the correct EGOhandle)
data_mp <- key %>%
filter(Elected20170315 == "yes, verkozen" & !(EGOhandle %in% c(10401, 10403, 13102, 15102, 106101,
41400)))
dg <- data_mp %>%
group_by(Geslacht) %>%
summarize(count = n(), freq = count/150)
de <- data_mp %>%
group_by(EthMinZ) %>%
summarize(count = n(), freq = count/150)
da <- data_mp %>%
mutate(variable = "AGE") %>%
summarize(age = first(variable), mean = mean(2017 - GebJaar, na.rm = T), sd = sd(2017 - GebJaar,
na.rm = T))
dp <- data_mp %>%
group_by(Partij) %>%
summarize(count = n(), freq = count/150) %>%
arrange(desc(count))
# by party
dgp <- data_mp %>%
group_by(Partij) %>%
add_tally() %>%
group_by(Partij, Geslacht) %>%
summarize(count = n(), freq = count/first(n), first = first(n)) %>%
arrange(desc(first)) %>%
select("Partij", "Geslacht", "count", "freq")
dep <- data_mp %>%
group_by(Partij) %>%
add_tally() %>%
group_by(Partij, EthMinZ) %>%
summarize(count = n(), freq = count/first(n), first = first(n)) %>%
arrange(desc(first)) %>%
select("Partij", "EthMinZ", "count", "freq")
dap <- data_mp %>%
mutate(variable = "AGE") %>%
group_by(Partij) %>%
add_tally() %>%
summarize(age = first(variable), mean = mean(2017 - GebJaar, na.rm = T), sd = sd(2017 - GebJaar,
na.rm = T), first = first(n)) %>%
arrange(desc(first)) %>%
select("Partij", "age", "mean", "sd")
dg <- dg %>%
add_column(grouping = "NO", .before = "Geslacht")
da <- da %>%
add_column(grouping = "NO", .before = "age")
de <- de %>%
add_column(grouping = "NO", .before = "EthMinZ")
dp <- dp %>%
add_column(grouping = "NO", .before = "Partij")
# dgp dap dep
# write_csv(dg, 'table.csv') write_csv(da, 'table.csv', append = TRUE) write_csv(de, 'table.csv',
# append = TRUE) write_csv(dp, 'table.csv', append = TRUE) write_csv(dgp, 'table.csv', append =
# TRUE) write_csv(dap, 'table.csv', append = TRUE) write_csv(dep, 'table.csv', append = TRUE)
test <- read_csv("table.csv")
colnames(test) <- c("grouping", "social dimension", "N / mean", "prop. / SD")
test$grouping[test$grouping == "NO"] <- "HoP"
test[test == "man"] <- "male"
test[test == "vrouw"] <- "female"
test[test == "0"] <- "no visible minority"
test[, 2][test[, 2] == "1"] <- "visible minority"
AppendixA <- kbl(test, booktabs = TRUE, digits = 2, caption = "Appendix A. Composition of parliament and political parties in the Netherlands (2017)",
align = "c") %>%
kable_classic(full_width = F, html_font = "Cambria") %>%
kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"))
scroll_box(AppendixA, width = "100%", height = "500px")
# save_kable(AppendixA, 'AppendixA.html')
grouping | social dimension | N / mean | prop. / SD |
---|---|---|---|
HoP | male | 96.00 | 0.64 |
HoP | female | 54.00 | 0.36 |
HoP | AGE | 45.13 | 9.32 |
HoP | no visible minority | 134.00 | 0.89 |
HoP | visible minority | 16.00 | 0.11 |
HoP | VVD | 33.00 | 0.22 |
HoP | PVV | 20.00 | 0.13 |
HoP | CDA | 19.00 | 0.13 |
HoP | D66 | 19.00 | 0.13 |
HoP | GroenLinks | 14.00 | 0.09 |
HoP | SP | 14.00 | 0.09 |
HoP | PvdA | 9.00 | 0.06 |
HoP | CU | 5.00 | 0.03 |
HoP | PvdDieren | 5.00 | 0.03 |
HoP | 50Plus | 4.00 | 0.03 |
HoP | DENK | 3.00 | 0.02 |
HoP | SGP | 3.00 | 0.02 |
HoP | FvD | 2.00 | 0.01 |
VVD | male | 23.00 | 0.70 |
VVD | female | 10.00 | 0.30 |
PVV | male | 14.00 | 0.70 |
PVV | female | 6.00 | 0.30 |
CDA | male | 13.00 | 0.68 |
CDA | female | 6.00 | 0.32 |
D66 | male | 12.00 | 0.63 |
D66 | female | 7.00 | 0.37 |
GroenLinks | male | 6.00 | 0.43 |
GroenLinks | female | 8.00 | 0.57 |
SP | male | 9.00 | 0.64 |
SP | female | 5.00 | 0.36 |
PvdA | male | 4.00 | 0.44 |
PvdA | female | 5.00 | 0.56 |
CU | male | 3.00 | 0.60 |
CU | female | 2.00 | 0.40 |
PvdDieren | male | 2.00 | 0.40 |
PvdDieren | female | 3.00 | 0.60 |
50Plus | male | 2.00 | 0.50 |
50Plus | female | 2.00 | 0.50 |
DENK | male | 3.00 | 1.00 |
SGP | male | 3.00 | 1.00 |
FvD | male | 2.00 | 1.00 |
VVD | AGE | 44.03 | 6.72 |
PVV | AGE | 46.05 | 10.09 |
CDA | AGE | 44.79 | 7.84 |
D66 | AGE | 43.84 | 10.16 |
GroenLinks | AGE | 47.14 | 10.08 |
SP | AGE | 38.36 | 6.99 |
PvdA | AGE | 44.89 | 7.99 |
CU | AGE | 46.80 | 4.38 |
PvdDieren | AGE | 45.20 | 8.26 |
50Plus | AGE | 64.75 | 8.02 |
DENK | AGE | 42.33 | 5.51 |
SGP | AGE | 52.33 | 7.57 |
FvD | AGE | 53.50 | 27.58 |
VVD | no visible minority | 30.00 | 0.91 |
VVD | visible minority | 3.00 | 0.09 |
PVV | no visible minority | 19.00 | 0.95 |
PVV | visible minority | 1.00 | 0.05 |
CDA | no visible minority | 18.00 | 0.95 |
CDA | visible minority | 1.00 | 0.05 |
D66 | no visible minority | 17.00 | 0.89 |
D66 | visible minority | 2.00 | 0.11 |
GroenLinks | no visible minority | 11.00 | 0.79 |
GroenLinks | visible minority | 3.00 | 0.21 |
SP | no visible minority | 12.00 | 0.86 |
SP | visible minority | 2.00 | 0.14 |
PvdA | no visible minority | 8.00 | 0.89 |
PvdA | visible minority | 1.00 | 0.11 |
CU | no visible minority | 5.00 | 1.00 |
PvdDieren | no visible minority | 5.00 | 1.00 |
50Plus | no visible minority | 4.00 | 1.00 |
DENK | visible minority | 3.00 | 1.00 |
SGP | no visible minority | 3.00 | 1.00 |
FvD | no visible minority | 2.00 | 1.00 |
# We retrieve the data from the RSiena data-object
fnet <- mydata$depvars$fnet
atmnet <- mydata$depvars$atmnet
rtnet <- mydata$depvars$rtnet
vrouw <- mydata$cCovars$vrouw
partij <- mydata$cCovars$partij
ethminz <- mydata$cCovars$ethminz
lft <- mydata$cCovars$lft
ethminz <- ethminz + attributes(ethminz)$mean
partij <- partij + attributes(partij)$mean
vrouw <- vrouw + attributes(vrouw)$mean
lft <- lft + attributes(lft)$mean
vrouwm <- fhomomat(vrouw)
partijm <- fhomomat(partij)
ethminzm <- fhomomat(ethminz)
xmat <- matrix(ethminz, nrow = length(ethminz), ncol = length(ethminz))
xmatt <- t(xmat)
minoritym <- xmat == 1 & xmatt == 1
# for age max 5 year difference / for descriptives
xmat <- matrix(lft, nrow = length(lft), ncol = length(lft))
xmatt <- t(xmat)
lftm <- (abs(xmat - xmatt) < 6)
# fndyads2(fnet[,,1], vrouwm) fndyads2(fnet[,,3], vrouwm) fndyads2(fnet[,,1], partijm)
# fndyads2(fnet[,,3], partijm) fndyads2(fnet[,,1], ethminzm) fndyads2(fnet[,,3], ethminzm)
desmat <- matrix(NA, nrow = 10, ncol = 9)
desmat[1, 1] <- fdensity(fnet[, , 1])
desmat[1, 2] <- fdensity(fnet[, , 2])
desmat[1, 3] <- fdensity(fnet[, , 3])
desmat[2, 1] <- fdensityintra(fnet[, , 1], vrouwm)
desmat[2, 2] <- fdensityintra(fnet[, , 2], vrouwm)
desmat[2, 3] <- fdensityintra(fnet[, , 3], vrouwm)
desmat[3, 1] <- fdensityinter(fnet[, , 1], vrouwm)
desmat[3, 2] <- fdensityinter(fnet[, , 2], vrouwm)
desmat[3, 3] <- fdensityinter(fnet[, , 3], vrouwm)
desmat[4, 1] <- fdensityintra(fnet[, , 1], partijm)
desmat[4, 2] <- fdensityintra(fnet[, , 2], partijm)
desmat[4, 3] <- fdensityintra(fnet[, , 3], partijm)
desmat[5, 1] <- fdensityinter(fnet[, , 1], partijm)
desmat[5, 2] <- fdensityinter(fnet[, , 2], partijm)
desmat[5, 3] <- fdensityinter(fnet[, , 3], partijm)
desmat[6, 1] <- fdensityintra(fnet[, , 1], ethminzm)
desmat[6, 2] <- fdensityintra(fnet[, , 2], ethminzm)
desmat[6, 3] <- fdensityintra(fnet[, , 3], ethminzm)
desmat[7, 1] <- fdensityinter(fnet[, , 1], ethminzm)
desmat[7, 2] <- fdensityinter(fnet[, , 2], ethminzm)
desmat[7, 3] <- fdensityinter(fnet[, , 3], ethminzm)
desmat[8, 1] <- fdensityinter(fnet[, , 1], minoritym)
desmat[8, 2] <- fdensityinter(fnet[, , 2], minoritym)
desmat[8, 3] <- fdensityinter(fnet[, , 3], minoritym)
desmat[9, 1] <- fdensityintra(fnet[, , 1], lftm)
desmat[9, 2] <- fdensityintra(fnet[, , 2], lftm)
desmat[9, 3] <- fdensityintra(fnet[, , 3], lftm)
desmat[10, 1] <- fdensityinter(fnet[, , 1], lftm)
desmat[10, 2] <- fdensityinter(fnet[, , 2], lftm)
desmat[10, 3] <- fdensityinter(fnet[, , 3], lftm)
desmat[1, 1 + 3] <- fdensity(atmnet[, , 1])
desmat[1, 2 + 3] <- fdensity(atmnet[, , 2])
desmat[1, 3 + 3] <- fdensity(atmnet[, , 3])
desmat[2, 1 + 3] <- fdensityintra(atmnet[, , 1], vrouwm)
desmat[2, 2 + 3] <- fdensityintra(atmnet[, , 2], vrouwm)
desmat[2, 3 + 3] <- fdensityintra(atmnet[, , 3], vrouwm)
desmat[3, 1 + 3] <- fdensityinter(atmnet[, , 1], vrouwm)
desmat[3, 2 + 3] <- fdensityinter(atmnet[, , 2], vrouwm)
desmat[3, 3 + 3] <- fdensityinter(atmnet[, , 3], vrouwm)
desmat[4, 1 + 3] <- fdensityintra(atmnet[, , 1], partijm)
desmat[4, 2 + 3] <- fdensityintra(atmnet[, , 2], partijm)
desmat[4, 3 + 3] <- fdensityintra(atmnet[, , 3], partijm)
desmat[5, 1 + 3] <- fdensityinter(atmnet[, , 1], partijm)
desmat[5, 2 + 3] <- fdensityinter(atmnet[, , 2], partijm)
desmat[5, 3 + 3] <- fdensityinter(atmnet[, , 3], partijm)
desmat[6, 1 + 3] <- fdensityintra(atmnet[, , 1], ethminzm)
desmat[6, 2 + 3] <- fdensityintra(atmnet[, , 2], ethminzm)
desmat[6, 3 + 3] <- fdensityintra(atmnet[, , 3], ethminzm)
desmat[7, 1 + 3] <- fdensityinter(atmnet[, , 1], ethminzm)
desmat[7, 2 + 3] <- fdensityinter(atmnet[, , 2], ethminzm)
desmat[7, 3 + 3] <- fdensityinter(atmnet[, , 3], ethminzm)
desmat[8, 1 + 3] <- fdensityinter(atmnet[, , 1], minoritym)
desmat[8, 2 + 3] <- fdensityinter(atmnet[, , 2], minoritym)
desmat[8, 3 + 3] <- fdensityinter(atmnet[, , 3], minoritym)
desmat[9, 1 + 3] <- fdensityintra(atmnet[, , 1], lftm)
desmat[9, 2 + 3] <- fdensityintra(atmnet[, , 2], lftm)
desmat[9, 3 + 3] <- fdensityintra(atmnet[, , 3], lftm)
desmat[10, 1 + 3] <- fdensityinter(atmnet[, , 1], lftm)
desmat[10, 2 + 3] <- fdensityinter(atmnet[, , 2], lftm)
desmat[10, 3 + 3] <- fdensityinter(atmnet[, , 3], lftm)
desmat[1, 1 + 6] <- fdensity(rtnet[, , 1])
desmat[1, 2 + 6] <- fdensity(rtnet[, , 2])
desmat[1, 3 + 6] <- fdensity(rtnet[, , 3])
desmat[2, 1 + 6] <- fdensityintra(rtnet[, , 1], vrouwm)
desmat[2, 2 + 6] <- fdensityintra(rtnet[, , 2], vrouwm)
desmat[2, 3 + 6] <- fdensityintra(rtnet[, , 3], vrouwm)
desmat[3, 1 + 6] <- fdensityinter(rtnet[, , 1], vrouwm)
desmat[3, 2 + 6] <- fdensityinter(rtnet[, , 2], vrouwm)
desmat[3, 3 + 6] <- fdensityinter(rtnet[, , 3], vrouwm)
desmat[4, 1 + 6] <- fdensityintra(rtnet[, , 1], partijm)
desmat[4, 2 + 6] <- fdensityintra(rtnet[, , 2], partijm)
desmat[4, 3 + 6] <- fdensityintra(rtnet[, , 3], partijm)
desmat[5, 1 + 6] <- fdensityinter(rtnet[, , 1], partijm)
desmat[5, 2 + 6] <- fdensityinter(rtnet[, , 2], partijm)
desmat[5, 3 + 6] <- fdensityinter(rtnet[, , 3], partijm)
desmat[6, 1 + 6] <- fdensityintra(rtnet[, , 1], ethminzm)
desmat[6, 2 + 6] <- fdensityintra(rtnet[, , 2], ethminzm)
desmat[6, 3 + 6] <- fdensityintra(rtnet[, , 3], ethminzm)
desmat[7, 1 + 6] <- fdensityinter(rtnet[, , 1], ethminzm)
desmat[7, 2 + 6] <- fdensityinter(rtnet[, , 2], ethminzm)
desmat[7, 3 + 6] <- fdensityinter(rtnet[, , 3], ethminzm)
desmat[8, 1 + 6] <- fdensityinter(rtnet[, , 1], minoritym)
desmat[8, 2 + 6] <- fdensityinter(rtnet[, , 2], minoritym)
desmat[8, 3 + 6] <- fdensityinter(rtnet[, , 3], minoritym)
desmat[9, 1 + 6] <- fdensityintra(rtnet[, , 1], lftm)
desmat[9, 2 + 6] <- fdensityintra(rtnet[, , 2], lftm)
desmat[9, 3 + 6] <- fdensityintra(rtnet[, , 3], lftm)
desmat[10, 1 + 6] <- fdensityinter(rtnet[, , 1], lftm)
desmat[10, 2 + 6] <- fdensityinter(rtnet[, , 2], lftm)
desmat[10, 3 + 6] <- fdensityinter(rtnet[, , 3], lftm)
colnames(desmat) <- c("following T1", "following T2", "following T3", "atmentions T1", "atmentions T2",
"atmentions T3", "retweets T1", "retweets T2", "retweets T3")
rownames(desmat) <- c("total", "same sex", "different sex", "same party", "different party", "same ethnicity",
"different ethnicity", "both minority", "same age (<6)", "different age (>5)")
# desmat write.csv2(desmat, '20190829desmat.csv')
desmatkable <- kbl(desmat, booktabs = TRUE, digits = 2, caption = "Table 1. Inter- and intra-group densities within the three Twitter layers among Dutch MPs (2017)",
align = "c") %>%
kable_classic(full_width = F, html_font = "Cambria") %>%
kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive")) %>%
column_spec(column = 1, width = "3in")
desmatkable
following T1 | following T2 | following T3 | atmentions T1 | atmentions T2 | atmentions T3 | retweets T1 | retweets T2 | retweets T3 | |
---|---|---|---|---|---|---|---|---|---|
total | 0.25 | 0.28 | 0.28 | 0.05 | 0.04 | 0.01 | 0.05 | 0.03 | 0.03 |
same sex | 0.26 | 0.29 | 0.29 | 0.05 | 0.04 | 0.01 | 0.05 | 0.03 | 0.03 |
different sex | 0.24 | 0.27 | 0.27 | 0.04 | 0.03 | 0.01 | 0.05 | 0.03 | 0.03 |
same party | 0.71 | 0.73 | 0.74 | 0.20 | 0.14 | 0.06 | 0.34 | 0.25 | 0.25 |
different party | 0.19 | 0.22 | 0.22 | 0.03 | 0.02 | 0.01 | 0.01 | 0.01 | 0.01 |
same ethnicity | 0.27 | 0.29 | 0.29 | 0.05 | 0.04 | 0.01 | 0.05 | 0.03 | 0.03 |
different ethnicity | 0.21 | 0.24 | 0.24 | 0.05 | 0.03 | 0.01 | 0.04 | 0.03 | 0.03 |
both minority | 0.25 | 0.28 | 0.28 | 0.05 | 0.03 | 0.01 | 0.05 | 0.03 | 0.03 |
same age (<6) | 0.29 | 0.31 | 0.31 | 0.06 | 0.04 | 0.01 | 0.05 | 0.04 | 0.04 |
different age (>5) | 0.24 | 0.26 | 0.26 | 0.04 | 0.03 | 0.01 | 0.04 | 0.03 | 0.03 |
A slightly different order of social dimensions (rows) as compared to manuscript but same numbers.
fnet[fnet == 10] <- NA
rtnet[rtnet == 10] <- NA
atmnet[atmnet == 10] <- NA
colmat <- matrix(NA, nrow = 3, ncol = 9)
colmat[1, 1] <- fscolnet(fnet[, , 1], partij)
colmat[1, 2] <- fscolnet(fnet[, , 2], partij)
colmat[1, 3] <- fscolnet(fnet[, , 3], partij)
colmat[1, 4] <- fscolnet(atmnet[, , 1], partij)
colmat[1, 5] <- fscolnet(atmnet[, , 2], partij)
colmat[1, 6] <- fscolnet(atmnet[, , 3], partij)
colmat[1, 7] <- fscolnet(rtnet[, , 1], partij)
colmat[1, 8] <- fscolnet(rtnet[, , 2], partij)
colmat[1, 9] <- fscolnet(rtnet[, , 3], partij)
colmat[2, 1] <- fscolnet(fnet[, , 1], vrouw)
colmat[2, 2] <- fscolnet(fnet[, , 2], vrouw)
colmat[2, 3] <- fscolnet(fnet[, , 3], vrouw)
colmat[2, 4] <- fscolnet(atmnet[, , 1], vrouw)
colmat[2, 5] <- fscolnet(atmnet[, , 2], vrouw)
colmat[2, 6] <- fscolnet(atmnet[, , 3], vrouw)
colmat[2, 7] <- fscolnet(rtnet[, , 1], vrouw)
colmat[2, 8] <- fscolnet(rtnet[, , 2], vrouw)
colmat[2, 9] <- fscolnet(rtnet[, , 3], vrouw)
colmat[3, 1] <- fscolnet(fnet[, , 1], ethminz)
colmat[3, 2] <- fscolnet(fnet[, , 2], ethminz)
colmat[3, 3] <- fscolnet(fnet[, , 3], ethminz)
colmat[3, 4] <- fscolnet(atmnet[, , 1], ethminz)
colmat[3, 5] <- fscolnet(atmnet[, , 2], ethminz)
colmat[3, 6] <- fscolnet(atmnet[, , 3], ethminz)
colmat[3, 7] <- fscolnet(rtnet[, , 1], ethminz)
colmat[3, 8] <- fscolnet(rtnet[, , 2], ethminz)
colmat[3, 9] <- fscolnet(rtnet[, , 3], ethminz)
colnames(colmat) <- c("following T1", "following T2", "following T3", "atmentions T1", "atmentions T2",
"atmentions T3", "retweets T1", "retweets T2", "retweets T3")
rownames(colmat) <- c("party", "sex", "ethnicity")
# colmat
# write.csv2(colmat, '20190829colmat.csv')
colmatkable <- kbl(colmat, booktabs = TRUE, digits = 2, caption = "Table 2. Coleman’s Homophily Index within the three Twitter layers among Dutch MPs (2017)",
align = "c") %>%
kable_classic(full_width = F, html_font = "Cambria") %>%
kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive")) %>%
column_spec(column = 1, width = "3in")
colmatkable
following T1 | following T2 | following T3 | atmentions T1 | atmentions T2 | atmentions T3 | retweets T1 | retweets T2 | retweets T3 | |
---|---|---|---|---|---|---|---|---|---|
party | 0.23 | 0.21 | 0.21 | 0.39 | 0.40 | 0.48 | 0.80 | 0.80 | 0.80 |
sex | 0.05 | 0.04 | 0.04 | 0.07 | 0.03 | 0.05 | -0.01 | -0.03 | -0.01 |
ethnicity | 0.12 | 0.10 | 0.10 | -0.03 | 0.00 | -0.02 | 0.05 | -0.01 | -0.01 |
fnet[fnet == 10] <- NA
rtnet[rtnet == 10] <- NA
atmnet[atmnet == 10] <- NA
vrouw_int <- as.integer(vrouw) + 1
partij_int <- as.integer(partij)
ethminz <- ethminz + 1
asmat <- matrix(NA, nrow = 4, ncol = 9)
gfnet1 <- graph_from_adjacency_matrix(fnet[, , 1], mode = "directed", weighted = NULL, diag = FALSE,
add.colnames = NA, add.rownames = NA)
gfnet2 <- graph_from_adjacency_matrix(fnet[, , 2], mode = "directed", weighted = NULL, diag = FALSE,
add.colnames = NA, add.rownames = NA)
gfnet3 <- graph_from_adjacency_matrix(fnet[, , 3], mode = "directed", weighted = NULL, diag = FALSE,
add.colnames = NA, add.rownames = NA)
grtnet1 <- graph_from_adjacency_matrix(rtnet[, , 1], mode = "directed", weighted = NULL, diag = FALSE,
add.colnames = NA, add.rownames = NA)
grtnet2 <- graph_from_adjacency_matrix(rtnet[, , 2], mode = "directed", weighted = NULL, diag = FALSE,
add.colnames = NA, add.rownames = NA)
grtnet3 <- graph_from_adjacency_matrix(rtnet[, , 3], mode = "directed", weighted = NULL, diag = FALSE,
add.colnames = NA, add.rownames = NA)
gatmnet1 <- graph_from_adjacency_matrix(atmnet[, , 1], mode = "directed", weighted = NULL, diag = FALSE,
add.colnames = NA, add.rownames = NA)
gatmnet2 <- graph_from_adjacency_matrix(atmnet[, , 2], mode = "directed", weighted = NULL, diag = FALSE,
add.colnames = NA, add.rownames = NA)
gatmnet3 <- graph_from_adjacency_matrix(atmnet[, , 3], mode = "directed", weighted = NULL, diag = FALSE,
add.colnames = NA, add.rownames = NA)
asmat[1, 1] <- assortativity_nominal(gfnet1, types = partij_int, directed = TRUE)
asmat[1, 2] <- assortativity_nominal(gfnet2, types = partij_int, directed = TRUE)
asmat[1, 3] <- assortativity_nominal(gfnet3, types = partij_int, directed = TRUE)
asmat[2, 1] <- assortativity_nominal(gfnet1, types = vrouw_int, directed = TRUE)
asmat[2, 2] <- assortativity_nominal(gfnet2, types = vrouw_int, directed = TRUE)
asmat[2, 3] <- assortativity_nominal(gfnet3, types = vrouw_int, directed = TRUE)
asmat[3, 1] <- assortativity_nominal(gfnet1, types = ethminz, directed = TRUE)
asmat[3, 2] <- assortativity_nominal(gfnet2, types = ethminz, directed = TRUE)
asmat[3, 3] <- assortativity_nominal(gfnet3, types = ethminz, directed = TRUE)
asmat[4, 1] <- assortativity(gfnet1, types1 = lft, directed = TRUE)
asmat[4, 2] <- assortativity(gfnet2, types1 = lft, directed = TRUE)
asmat[4, 3] <- assortativity(gfnet3, types1 = lft, directed = TRUE)
asmat[1, 7] <- assortativity_nominal(grtnet1, types = partij_int, directed = TRUE)
asmat[1, 8] <- assortativity_nominal(grtnet2, types = partij_int, directed = TRUE)
asmat[1, 9] <- assortativity_nominal(grtnet3, types = partij_int, directed = TRUE)
asmat[2, 7] <- assortativity_nominal(grtnet1, types = vrouw_int, directed = TRUE)
asmat[2, 8] <- assortativity_nominal(grtnet2, types = vrouw_int, directed = TRUE)
asmat[2, 9] <- assortativity_nominal(grtnet3, types = vrouw_int, directed = TRUE)
asmat[3, 7] <- assortativity_nominal(grtnet1, types = ethminz, directed = TRUE)
asmat[3, 8] <- assortativity_nominal(grtnet2, types = ethminz, directed = TRUE)
asmat[3, 9] <- assortativity_nominal(grtnet3, types = ethminz, directed = TRUE)
asmat[4, 7] <- assortativity(grtnet1, types1 = lft, directed = TRUE)
asmat[4, 8] <- assortativity(grtnet2, types1 = lft, directed = TRUE)
asmat[4, 9] <- assortativity(grtnet3, types1 = lft, directed = TRUE)
asmat[1, 4] <- assortativity_nominal(gatmnet1, types = partij_int, directed = TRUE)
asmat[1, 5] <- assortativity_nominal(gatmnet2, types = partij_int, directed = TRUE)
asmat[1, 6] <- assortativity_nominal(gatmnet3, types = partij_int, directed = TRUE)
asmat[2, 4] <- assortativity_nominal(gatmnet1, types = vrouw_int, directed = TRUE)
asmat[2, 5] <- assortativity_nominal(gatmnet2, types = vrouw_int, directed = TRUE)
asmat[2, 6] <- assortativity_nominal(gatmnet3, types = vrouw_int, directed = TRUE)
asmat[3, 4] <- assortativity_nominal(gatmnet1, types = ethminz, directed = TRUE)
asmat[3, 5] <- assortativity_nominal(gatmnet2, types = ethminz, directed = TRUE)
asmat[3, 6] <- assortativity_nominal(gatmnet3, types = ethminz, directed = TRUE)
asmat[4, 4] <- assortativity(gatmnet1, types1 = lft, directed = TRUE)
asmat[4, 5] <- assortativity(gatmnet2, types1 = lft, directed = TRUE)
asmat[4, 6] <- assortativity(gatmnet3, types1 = lft, directed = TRUE)
colnames(asmat) <- c("following T1", "following T2", "following T3", "atmentions T1", "atmentions T2",
"atmentions T3", "retweets T1", "retweets T2", "retweets T3")
rownames(asmat) <- c("party", "sex", "ethnicity", "age")
# asmat write.csv2(asmat, '20190828asmat.csv')
asmatkable <- kbl(asmat, booktabs = TRUE, digits = 2, caption = "Table 3. Newman’s Assortativity Coefficient within the three Twitter layers among Dutch MPs (2017)",
align = "c") %>%
kable_classic(full_width = F, html_font = "Cambria") %>%
kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive")) %>%
column_spec(column = 1, width = "3in")
asmatkable
following T1 | following T2 | following T3 | atmentions T1 | atmentions T2 | atmentions T3 | retweets T1 | retweets T2 | retweets T3 | |
---|---|---|---|---|---|---|---|---|---|
party | 0.22 | 0.20 | 0.20 | 0.39 | 0.39 | 0.47 | 0.82 | 0.83 | 0.83 |
sex | 0.04 | 0.03 | 0.04 | 0.10 | 0.04 | 0.06 | 0.01 | -0.01 | 0.02 |
ethnicity | 0.06 | 0.05 | 0.05 | 0.08 | 0.02 | -0.07 | 0.09 | 0.02 | 0.04 |
age | 0.05 | 0.04 | 0.04 | 0.09 | 0.02 | 0.12 | 0.02 | 0.01 | 0.06 |
following T1 | following T2 | following T3 | atmentions T1 | atmentions T2 | atmentions T3 | retweets T1 | retweets T2 | retweets T3 | |
---|---|---|---|---|---|---|---|---|---|
VVD (32) | 0.34 | 0.33 | 0.33 | 0.86 | 0.82 | 0.87 | 0.41 | 0.35 | 0.41 |
CDA (19) | 0.24 | 0.22 | 0.23 | 0.83 | 0.80 | 0.76 | 0.53 | 0.56 | 0.50 |
D66 (19) | 0.21 | 0.19 | 0.17 | 0.89 | 0.85 | 0.85 | 0.48 | 0.45 | 0.57 |
PVV (18) | 0.52 | 0.48 | 0.47 | 0.94 | 0.98 | 0.98 | 0.27 | 0.63 | 0.43 |
SP (14) | 0.29 | 0.19 | 0.25 | 0.86 | 0.90 | 0.90 | 0.40 | 0.39 | 0.58 |
GroenLinks (14) | 0.20 | 0.17 | 0.17 | 0.73 | 0.81 | 0.75 | 0.39 | 0.39 | 0.38 |
PvdA (9) | 0.12 | 0.11 | 0.10 | 0.80 | 0.52 | 0.44 | 0.32 | 0.22 | 0.23 |
CU (5) | 0.09 | 0.09 | 0.09 | 0.56 | 0.54 | 0.60 | 0.36 | 0.21 | 0.31 |
PvdDieren (5) | 0.05 | 0.04 | 0.04 | 0.60 | 0.73 | 0.88 | 0.26 | 0.31 | 0.61 |
50Plus (4) | 0.09 | 0.10 | 0.10 | 1.00 | 0.59 | 0.71 | 0.29 | 0.32 | 1.00 |
DENK (3) | 0.06 | 0.06 | 0.06 | 0.66 | 1.00 | 0.39 | 0.26 | 0.19 | -1.00 |
SGP (3) | 0.01 | 0.01 | 0.01 | 0.37 | 0.26 | 0.57 | 0.28 | 0.32 | NaN |
FvD (2) | 0.14 | 0.12 | 0.08 | 0.19 | NaN | 0.50 | 0.14 | -1.00 | -1.00 |
Copyright © 2021 Jochem Tolsma