improve vignette
This commit is contained in:
+18
@@ -11,3 +11,21 @@ join_redner <- function(tb, res, fraktion_only = F) {
|
|||||||
if (fraktion_only) select(joined, "fraktion")
|
if (fraktion_only) select(joined, "fraktion")
|
||||||
else joined
|
else joined
|
||||||
}
|
}
|
||||||
|
|
||||||
|
party_colors <- c(
|
||||||
|
SPD="#DF0B25",
|
||||||
|
"CDU/CSU"="#000000",
|
||||||
|
AfD="#1A9FDD",
|
||||||
|
"AfD&Fraktionslos"="#1A9FDD",
|
||||||
|
"DIE LINKE"="#BC3475",
|
||||||
|
"BÜNDNIS 90 / DIE GRÜNEN"="#4A932B",
|
||||||
|
FDP="#FEEB34",
|
||||||
|
Fraktionslos="#FEEB34"
|
||||||
|
)
|
||||||
|
|
||||||
|
#' @export
|
||||||
|
bar_plot_fraktionen <- function(tb) {
|
||||||
|
ggplot(tb, aes(x = reorder(fraktion, -n), y = n, fill = fraktion)) +
|
||||||
|
scale_fill_manual(values = party_colors) +
|
||||||
|
geom_bar(stat = "identity")
|
||||||
|
}
|
||||||
|
|||||||
@@ -22,6 +22,11 @@ Um dokumentationen neu zu laden / zu erstellen (ruft roxgen auf)
|
|||||||
document()
|
document()
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Baue vignetten
|
||||||
|
```r
|
||||||
|
rmarkdown::render("vignettes/bla.Rmd")
|
||||||
|
```
|
||||||
|
|
||||||
# Herunterladen
|
# Herunterladen
|
||||||
|
|
||||||
Bevor analysiert werden kann, muss fetch.R ausgeführt werden, um alle Protokolle herunterzuladen.
|
Bevor analysiert werden kann, muss fetch.R ausgeführt werden, um alle Protokolle herunterzuladen.
|
||||||
|
|||||||
+15
-16
@@ -29,43 +29,42 @@ 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:
|
Second, those `.xml` files, need to be parsed into `R` `tibbles`. This is accomplished by:
|
||||||
```r
|
```r
|
||||||
read_all("../records/") %>% repair() -> res
|
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
|
We also used `repair` to fix a bunch of formatting issues in the records and unpacked
|
||||||
the result into more descriptive variables.
|
the result into more descriptive variables.
|
||||||
|
|
||||||
For development purposes, we load the tables from csv files.
|
For development purposes, we load the tables from csv files.
|
||||||
```{r}
|
```{r}
|
||||||
tables <- read_from_csv('../csv/')
|
res <- read_from_csv('../csv/')
|
||||||
|
```
|
||||||
comments <- tables$comments
|
and unpack our tibbles
|
||||||
reden <- tables$reden
|
```{r}
|
||||||
redner <- tables$redner
|
comments <- res$comments
|
||||||
talks <- tables$talks
|
reden <- res$reden
|
||||||
|
redner <- res$redner
|
||||||
|
talks <- res$talks
|
||||||
```
|
```
|
||||||
|
|
||||||
## Analysis
|
## Analysis
|
||||||
|
|
||||||
Now we can start analysing our parsed dataset, e.g. find out which party gives the most talks:
|
Now we can start analysing our parsed dataset, e.g. find out which party gives the most talks:
|
||||||
```{r}
|
```{r, fig.width=10}
|
||||||
left_join(reden, redner, by=c("redner" = "id")) %>%
|
join_redner(reden, res) %>%
|
||||||
group_by(fraktion) %>%
|
group_by(fraktion) %>%
|
||||||
summarize(n = n()) %>%
|
summarize(n = n()) %>%
|
||||||
ggplot(aes(x = fraktion, y = n)) +
|
arrange(n) %>%
|
||||||
geom_bar(stat = "identity")
|
bar_plot_fraktionen()
|
||||||
```
|
```
|
||||||
|
|
||||||
### Count a word occurence
|
### Count a word occurence
|
||||||
|
|
||||||
```{r}
|
```{r, fig.width=10}
|
||||||
find_word(res, "hitler") %>%
|
find_word(res, "hitler") %>%
|
||||||
filter(occurences > 0) %>%
|
filter(occurences > 0) %>%
|
||||||
join_redner(res) %>%
|
join_redner(res) %>%
|
||||||
select(content, fraktion) %>%
|
select(content, fraktion) %>%
|
||||||
group_by(fraktion) %>%
|
group_by(fraktion) %>%
|
||||||
summarize(n = n()) %>%
|
summarize(n = n()) %>%
|
||||||
arrange(desc(n))
|
arrange(desc(n)) %>%
|
||||||
|
bar_plot_fraktionen()
|
||||||
```
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user