Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
L'AFSP, un congrès international(isé) ? – https://politbistro.hypotheses.org/5319
library(ggplot2)
library(readr)
d <- read_tsv("data/affiliations.tsv") %>%
filter(j != "2015_STRC20IPSA") %>%
mutate(
y = str_sub(j, 1, 4),
e = str_extract(affiliation, "\\((.*?)\\)") %>%
str_replace_all("\\(|\\)", "")
) %>%
select(-j) %>%
distinct # remove duplicates (same participants in 2+ panels)
t <- filter(d, !e %in% c("UE", "INTERNATIONAL")) %>%
group_by(y) %>%
summarise(
n = sum(!is.na(affiliation)),
n_m = sum(is.na(affiliation)), # missing values
p_m = n_m / n,
n_e = sum(!is.na(e)), # foreign institutions
p_e = n_e / n
)
ggplot(t, aes(y, p_e)) +
geom_col() +
geom_text(aes(label = paste(round(100 * p_e), "%")), vjust = 2, color = "gold") +
geom_text(aes(y = 0.075, label = paste("P\n", n)), color = "white") +
geom_text(aes(y = 0.025, label = paste("E\n", n_e)), color = "white") +
scale_y_continuous(labels = scales::percent_format()) +
ylab("% participants basés à l'étranger\n") +
xlab("\nAnnée du Congrès AFSP") +
theme_bw(base_size = 14) +
theme(panel.grid = element_blank())
ggsave("congres-afsp-p_e.png")
filter(d, !is.na(e), !e %in% c("UE", "INTERNATIONAL")) %>%
group_by(e) %>%
count(sort = TRUE) %>%
ggplot(aes(reorder(e, n), n)) +
geom_col() +
coord_flip() +
ylab("\nNombre d'affiliations") +
xlab(NULL) +
theme_bw(base_size = 14)
ggsave("congres-afsp-e.png", height = 8)
print(t)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment