diff --git a/README.md b/README.md index afb6964..bb465e8 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ tables <- read_all() tables <- repair(tables) write_to_csv(tables) ``` -Wir verwenden NIEMALS source, etc.! Außerdem NIEMALD library(...) verwenden, sondern +Wir verwenden NIEMALS source, etc.! Außerdem NIEMALS library(...) verwenden, sondern um neue pakete hinzuzufuegen (als dependency), verwende: ```r use_package("my-good-old-package") @@ -40,7 +40,7 @@ Bevor analysiert werden kann, muss fetch.R ausgeführt werden, um alle Protokoll ## Tabellen -parse.R parsed einzelne Protokolle und erstellt 3 Tibbles +parse.R parsed einzelne Protokolle und erstellt 5 Tibbles ### Redner diff --git a/vignettes/genderequality.Rmd b/vignettes/genderequality.Rmd index 44e919b..c7253f6 100644 --- a/vignettes/genderequality.Rmd +++ b/vignettes/genderequality.Rmd @@ -92,5 +92,134 @@ gender <- tibble(speaker = names, gender = gender) +speaker %>% + unite("speaker", vorname, nachname, sep = " ") %>% + right_join(gender, by = "speaker") -> + speaker_with_gender + +``` + +#Analyse + +First, let's look at the relative distribution of the sexes throughout the whole Bundestag. + +```{r} +speaker_with_gender %>% + select(gender) %>% + group_by(gender) %>% + summarise("count" = n()) %>% + filter(gender %in% c("male", "female")) %>% + mutate(portion = 100*count/sum(count)) -> + plot1 + +bp <- ggplot(plot1, aes(x = "", y = portion, fill = gender))+ + geom_bar(width = 1, stat = "identity") +pie <- bp + coord_polar("y", start=0) +pie + + scale_fill_manual(values=c("pink", "blue")) + + ggtitle("Relative distribution of sexes") + + xlab("") + + ylab("") +``` + +Next we look at the individual distributions between men and women in relation to the individual parties. + +```{r} + +speaker_with_gender %>% + select(fraction, gender) %>% + group_by(fraction, gender) %>% + summarise("count" = n()) %>% + filter(gender %in% c("male", "female")) %>% + filter(!is.na(fraction)) %>% + group_by(fraction) %>% + mutate(portion = 100*count/sum(count)) -> + plot2 + +plot2 %>% + filter(fraction == "AfD") %>% + ggplot(aes(x = "", y = portion, fill = gender))+ + geom_bar(width = 1, stat = "identity") -> + bp +pie1 <- bp + coord_polar("y", start=0) + ggtitle("AfD") + xlab("") + ylab("") +plot2 %>% + filter(fraction == "BÜNDNIS 90 / DIE GRÜNEN") %>% + ggplot(aes(x = "", y = portion, fill = gender))+ + geom_bar(width = 1, stat = "identity") -> + bp +pie2 <- bp + coord_polar("y", start=0) + ggtitle("DIE GRÜNEN") + xlab("") + ylab("") +plot2 %>% + filter(fraction == "CDU/CSU") %>% + ggplot(aes(x = "", y = portion, fill = gender))+ + geom_bar(width = 1, stat = "identity") -> + bp +pie3 <- bp + coord_polar("y", start=0) + ggtitle("CDU/CSU") + xlab("") + ylab("") +plot2 %>% + filter(fraction == "DIE LINKE") %>% + ggplot(aes(x = "", y = portion, fill = gender))+ + geom_bar(width = 1, stat = "identity") -> + bp +pie4 <- bp + coord_polar("y", start=0) + ggtitle("DIE LINKE") + xlab("") + ylab("") +plot2 %>% + filter(fraction == "FDP") %>% + ggplot(aes(x = "", y = portion, fill = gender))+ + geom_bar(width = 1, stat = "identity") -> + bp +pie5 <- bp + coord_polar("y", start=0) + ggtitle("FDP") + xlab("") + ylab("") +plot2 %>% + filter(fraction == "SPD") %>% + ggplot(aes(x = "", y = portion, fill = gender))+ + geom_bar(width = 1, stat = "identity") -> + bp +pie6 <- bp + coord_polar("y", start=0) + ggtitle("SPD") + xlab("") + ylab("") + +gridExtra::grid.arrange(pie1,pie2,pie3,pie4,pie5,pie6,nrow=2) +``` + + + +```{r} + +speeches %>% + group_by(speaker) %>% + summarize(n = n()) %>% + ungroup() %>% + arrange(-n) %>% + left_join(speaker, by=c("speaker" = "id")) %>% + unite(name, vorname, nachname, sep = " ") %>% + inner_join(gender, by=c("name"= "speaker")) %>% + group_by(gender) %>% + summarise(absolute=sum(n)) %>% + filter(gender %in% c("female", "male")) %>% + mutate(absolute2=absolute/sum(absolute)) %>% + mutate(portion=c(0.32, 0.68)) %>% + mutate(relative=absolute*(1-portion)) %>% + mutate(relative2=relative/sum(relative)) -> + plot3 +``` + +```{r} +barplot(plot3$absolute2, + ylab = "amount of speeches", + main = "Absolute comparison of speech shares", + las = 1, + names.arg = c("women", "men"), + col = c("pink", "darkblue"), + font.main = 4, + cex.axis = 0.7) ``` +```{r} +barplot(plot3$relative2, + ylab = "amount of speeches", + main = "Relative comparison of speech shares", + las = 1, + names.arg = c("women", "men"), + col = c("pink", "darkblue"), + font.main = 4, + cex.axis = 0.7) +``` + + + +