An R package to analyze the parliamentary records of the 19th legislative period of the Bundestag, the German parliament.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
811B

  1. #' @export
  2. find_word <- function(res, word) {
  3. talks <- res$talks
  4. mutate(talks, occurences = sapply(str_match_all(talks$content, regex(word, ignore_case = TRUE)),
  5. nrow))
  6. }
  7. #' @export
  8. join_redner <- function(tb, res, fraktion_only = F) {
  9. joined <- left_join(tb, res$redner, by=c("redner" = "id"))
  10. if (fraktion_only) select(joined, "fraktion")
  11. else joined
  12. }
  13. party_colors <- c(
  14. SPD="#DF0B25",
  15. "CDU/CSU"="#000000",
  16. AfD="#1A9FDD",
  17. "AfD&Fraktionslos"="#1A9FDD",
  18. "DIE LINKE"="#BC3475",
  19. "BÜNDNIS 90 / DIE GRÜNEN"="#4A932B",
  20. FDP="#FEEB34",
  21. Fraktionslos="#FEEB34"
  22. )
  23. #' @export
  24. bar_plot_fraktionen <- function(tb) {
  25. ggplot(tb, aes(x = reorder(fraktion, -n), y = n, fill = fraktion)) +
  26. scale_fill_manual(values = party_colors) +
  27. geom_bar(stat = "identity")
  28. }