This commit is contained in:
2021-08-03 18:28:59 +02:00
3 changed files with 40 additions and 33 deletions
+4 -16
View File
@@ -13,6 +13,9 @@ read_all <- function(path="records/") {
available_protocols <- list.files(path)
res <- pblapply(available_protocols, read_one, path=path)
if (length(available_protocols) == 0)
stop("The given directory is empty or does not exist.")
lapply(res, `[[`, "speaker") %>%
bind_rows() %>%
distinct() ->
@@ -34,9 +37,6 @@ read_all <- function(path="records/") {
distinct() ->
commentsandapplause
if (length(available_protocols) == 0)
warning("The given directory is empty or does not exist.")
filter(commentsandapplause, type == "comment") %>%
select(-type) ->
comments
@@ -46,7 +46,7 @@ read_all <- function(path="records/") {
"SPD" = str_detect(fraction, "SPD"),
"FDP" = str_detect(fraction, "FDP"),
"DIE_LINKE" = str_detect(fraction, "DIE LINKE"),
"BÜNDNIS_90_DIE_GRÜNEN" = str_detect(fraction, "BÜNDNIS 90/DIE GRÜNEN"),
"BUENDNIS_90_DIE_GRUENEN" = str_detect(fraction, "BÜNDNIS 90/DIE GRÜNEN"),
"AfD" = str_detect(fraction, "AfD")) %>%
select(-fraction) ->
applause
@@ -227,15 +227,3 @@ read_from_csv <- function(path="csv/") {
comments = tibble %$% read.table(str_c(path, "comments.csv")),
applause = tibble %$% read.table(str_c(path, "applause.csv")))
}
# -------------------------------
# EXAMPLE USE
# make sure data ist downloaded via fetch.R
# res <- read_one("records/19126-data.xml")
#
# res$speaker
# res$speeches
# res$talks
# -------------------------------