|
|
|
@@ -14,23 +14,36 @@ knitr::opts_chunk$set( |
|
|
|
) |
|
|
|
``` |
|
|
|
|
|
|
|
```{r setup} |
|
|
|
library(hateimparlament) |
|
|
|
library(dplyr) |
|
|
|
library(ggplot2) |
|
|
|
``` |
|
|
|
|
|
|
|
## Preparation of data |
|
|
|
|
|
|
|
First, you need to download all records of the current legislative period. |
|
|
|
```r |
|
|
|
read_all() %>% repair() -> res |
|
|
|
fetch_all("../records/") # path to directory where records should be stored |
|
|
|
``` |
|
|
|
Second, those `.xml` files, need to be parsed into `R` `tibbles`. This is accomplished by: |
|
|
|
```{r} |
|
|
|
read_all("../records/") %>% repair() -> res |
|
|
|
|
|
|
|
reden <- res$reden |
|
|
|
redner <- res$redner |
|
|
|
talks <- res$talks |
|
|
|
``` |
|
|
|
We also used `repair` to fix a bunch of formatting issues in the records and unpacked |
|
|
|
the result into more descriptive variables. |
|
|
|
|
|
|
|
# first tries |
|
|
|
## Analysis |
|
|
|
|
|
|
|
Now we can start analysing our parsed dataset, e.g. find out which party gives the most talks: |
|
|
|
```{r} |
|
|
|
left_join(reden, redner, by=c("redner" = "id")) %>% |
|
|
|
group_by(fraktion) %>% |
|
|
|
summarize(n = n()) %>% |
|
|
|
ggplot(aes(x = fraktion, y = n)) + |
|
|
|
geom_bar(stat = "identity") |
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
```{r setup} |
|
|
|
library(hateimparlament) |
|
|
|
``` |