| @@ -1,6 +1,8 @@ | |||||
| # Generated by roxygen2: do not edit by hand | # Generated by roxygen2: do not edit by hand | ||||
| export(fetch_all) | export(fetch_all) | ||||
| export(find_word) | |||||
| export(join_redner) | |||||
| export(read_all) | export(read_all) | ||||
| export(read_from_csv) | export(read_from_csv) | ||||
| export(repair) | export(repair) | ||||
| @@ -0,0 +1,13 @@ | |||||
| #' @export | |||||
| find_word <- function(res, word) { | |||||
| talks <- res$talks | |||||
| mutate(talks, occurences = sapply(str_match_all(talks$content, regex(word, ignore_case = TRUE)), | |||||
| nrow)) | |||||
| } | |||||
| #' @export | |||||
| join_redner <- function(tb, res, fraktion_only = F) { | |||||
| joined <- left_join(tb, res$redner, by=c("redner" = "id")) | |||||
| if (fraktion_only) select(joined, "fraktion") | |||||
| else joined | |||||
| } | |||||
| @@ -57,3 +57,15 @@ left_join(reden, redner, by=c("redner" = "id")) %>% | |||||
| ggplot(aes(x = fraktion, y = n)) + | ggplot(aes(x = fraktion, y = n)) + | ||||
| geom_bar(stat = "identity") | geom_bar(stat = "identity") | ||||
| ``` | ``` | ||||
| ### Count a word occurence | |||||
| ```{r} | |||||
| find_word(res, "hitler") %>% | |||||
| filter(occurences > 0) %>% | |||||
| join_redner(res) %>% | |||||
| select(content, fraktion) %>% | |||||
| group_by(fraktion) %>% | |||||
| summarize(n = n()) %>% | |||||
| arrange(desc(n)) | |||||
| ``` | |||||