Alle benötigten Packages öffnen
rm(list=ls(all=TRUE))
p_needed <- c("tidyverse", "quanteda", "cld3", "ggpubr")
lapply(p_needed, library, character.only = TRUE)
## [[1]]
## [1] "forcats" "stringr" "dplyr" "purrr" "readr" "tidyr"
## [7] "tibble" "ggplot2" "tidyverse" "stats" "graphics" "grDevices"
## [13] "utils" "datasets" "methods" "base"
##
## [[2]]
## [1] "quanteda" "forcats" "stringr" "dplyr" "purrr" "readr"
## [7] "tidyr" "tibble" "ggplot2" "tidyverse" "stats" "graphics"
## [13] "grDevices" "utils" "datasets" "methods" "base"
##
## [[3]]
## [1] "cld3" "quanteda" "forcats" "stringr" "dplyr" "purrr"
## [7] "readr" "tidyr" "tibble" "ggplot2" "tidyverse" "stats"
## [13] "graphics" "grDevices" "utils" "datasets" "methods" "base"
##
## [[4]]
## [1] "ggpubr" "cld3" "quanteda" "forcats" "stringr" "dplyr"
## [7] "purrr" "readr" "tidyr" "tibble" "ggplot2" "tidyverse"
## [13] "stats" "graphics" "grDevices" "utils" "datasets" "methods"
## [19] "base"
rm(p_needed)
Daten einlesen
setwd("~/1 UZH/MA 8_FS 21/Forschungsseminar Datenjournalismus/Daten/Data Journalism 2021")
parl <- readRDS("~/1 UZH/MA 8_FS 21/Forschungsseminar Datenjournalismus/Daten/Data Journalism 2021/swiss_parl_debates.RDS")
Daten aufräumen gemäss Codebook und Doc-ID erstellen
tidy_debates <- function(debates){
debates <- debates %>% dplyr::mutate(speakers_chamber = gsub(" =//= $", " =//= NA", speakers_chamber),
speakers = gsub(" =//= $", " =//= NA", speakers),
canton = gsub(" =//= $", " =//= NA", canton),
fractions = gsub(" =//= $", " =//= NA", fractions),
texts = gsub(" =//= $", " =//= NA", texts),
votes_yes = gsub(" =//= $", " =//= NA", votes_yes),
votes_no = gsub(" =//= $", " =//= NA", votes_no),
absention_vote = gsub(" =//= $", " =//= NA", absention_vote)) %>%
dplyr::mutate(speakers_chamber = strsplit(as.character(speakers_chamber), " =//= "),
speakers = strsplit(as.character(speakers), " =//= "),
canton = strsplit(as.character(canton), " =//= "),
fractions = strsplit(as.character(fractions), " =//= "),
texts = strsplit(as.character(texts), " =//= "),
votes_yes = strsplit(as.character(votes_yes), " =//= "),
votes_no = strsplit(as.character(votes_no), " =//= "),
absention_vote = strsplit(as.character(absention_vote), " =//= ")) %>%
tidyr::unnest(cols = c(speakers_chamber, speakers, canton, fractions, texts, votes_yes,
votes_no,
absention_vote)) %>%
dplyr::mutate(id = row_number()) %>%
dplyr::group_by(debate_id) %>% dplyr::arrange(desc(id)) %>% dplyr::select(-id) %>%
dplyr::mutate(debate_id_order_id = seq_along(debate_id)) %>%
dplyr::select(debate_id, debate_id_order_id, business_id:absention_vote)
return(debates)
}
parl_tidy <- tidy_debates(parl)
parl_tidy <- parl_tidy %>%
group_by(session) %>%
mutate(number=str_pad(row_number(),width=4,pad="0"),
doc_id=paste0(session,number))
Variable Language und Corpus erstellen
#Sprache erkennen und nach Sprachen gruppiert Prozentsatz ausrechnen:
parl_tidy$language <- detect_language(parl_tidy$texts)
#Nach 'language' gruppiert habe ich mir die erkannten Sprachen angeschaut. Danach habe ich die falschen rausgefiltert und inspiziert. Diejenigen Sprachen, die falsch identifiziert wurden sind entweder "NAs" oder Protokollierungen wie "Urheber befriedigt".
#Sie wären also in meiner Analyse sowieso nicht vorgekommen.
#Daraus ergibt sich, dass die Spracherkennung gut funktioniert und mir keine wichtigen Daten eliminiert hat.
#Jahresvariable erstellen
parl_tidy <- parl_tidy %>%
mutate(date = as.Date(date, format = "%d.%m.%y")) %>%
mutate(year = lubridate::year(date))
#Allgemeiner Corpus
parl_corpus <- corpus(parl_tidy, text_field="texts")
#Französischer Corpus
francais <- parl_tidy %>%
filter(language %in% c("fr"))
parl_corpus_fr <- corpus(francais, text_field = "texts")
#Deutscher Corpus
deutsch <- parl_tidy %>%
filter(language %in% c("de"))
parl_corpus_de <- corpus(deutsch, text_field = "texts")
Tokenisieren
#Alle Tokens
parl_toks <- tokens(parl_corpus, remove_punct = TRUE, remove_numbers = TRUE, include_docvars = TRUE)
parl_toks <- parl_toks %>%
tokens_remove(stopwords('de')) %>%
tokens_remove(c("dass")) %>%
tokens_remove(stopwords('fr')) %>%
tokens_tolower()
#Französische Tokens
parl_toks_fr <- tokens(parl_corpus_fr, remove_punct = TRUE, remove_numbers = TRUE, include_docvars = TRUE)
parl_toks_fr <- parl_toks_fr %>%
tokens_remove(stopwords('fr')) %>%
tokens_tolower()
#Bei den französischen Tokens entferne ich alle 'L,S,D,N,M,T' mit einem nachfolgenden Apostroph. So entgehen sie mir nicht in den Dictionaries, und ich muss nicht an jede mögliche Variante denken
parl_toks_fr <- tokens_replace(parl_toks_fr, types(parl_toks_fr),
stringi::stri_replace_all_regex(types(parl_toks_fr), "[lsdnmt]['\\p{Pf}]", ""))
#Deutsche Tokens
parl_toks_de <- tokens(parl_corpus_de, remove_punct = TRUE, remove_numbers = TRUE, include_docvars = TRUE)
parl_toks_de <- parl_toks_de %>%
tokens_remove(stopwords('de')) %>%
tokens_remove(c("dass")) %>%
tokens_tolower()
Tokens für die Dictionaries vorbereiten
Negative Wörter im Pessimismus
#Deutsch
nohoffnungwords <- c("keine hoffnung","hoffnungslos","keine zuversicht","nicht zuversichtlich","nicht hoff*",
"keine chance", "kein grund zur hoffnung")
keinehoffnung <- rep("keinehoffnung", length(nohoffnungwords))
noconservewords <- c("nicht bewahren","nicht zu bewahren","nicht erhalten","nicht zu erhalten",
"nicht retten","nicht zu retten","nicht aufrechterhalten",
"nicht aufrecht zu erhalten","schutzlos","kein schutz")
nichtbewahren <- rep("nichtbewahren", length(noconservewords))
nomeisternwords <- c("nicht geschafft","nicht schaffen","nicht zu schaffen","nicht zu meistern*",
"nicht meistern","nicht gemeistert","nicht bestehen","nicht überwinden",
"nicht zu überwinden*","nicht zu bestehend*",
"nicht überwunden","nicht lösen","nicht gelöst","keine lösung","nicht bewältigen",
"nicht zu bewältigen*","nicht gebodigt*","nicht erreich*")
nichtmeistern <- rep("nichtmeistern", length(nomeisternwords))
nomöglichwords <- c("nicht möglich","unmöglich*","keine möglichkeit","kein potential","ohne potential",
"kein potentiell*","keine potentiell*","nicht machbar*","nicht ausführbar*",
"keine ausführbarkeit","nicht ausfzuführen","nicht praktikabel","unpraktikab*")
nichtmöglich <- rep("nichtmöglich", length(nomöglichwords))
parl_toks_de <- parl_toks_de %>%
tokens_replace(nohoffnungwords, keinehoffnung) %>%
tokens_replace(noconservewords, nichtbewahren) %>%
tokens_replace(nomeisternwords, nichtmeistern) %>%
tokens_replace(nomöglichwords, nichtmöglich)
#Französisch
motspasdespoir <- c("pas espoir","sans espoir","sans rien espérer","sans le moindre espoir","ne rien espérer",
"pas de confiance","pas confiant*","aucune chance","aucune raison espérer",
"pas de raison espérer")
sansespoir <- rep("sansespoir", length(motspasdespoir))
motsnonpreserver <- c("ne préserve pas","pas préservé*","ne pas maintenir","ne maintien*","pas maintenu*",
"sans protection","mal protégé*","pas suffisamment protégé*","non protégé*","ne protège*",
"sans défense")
paspreserver <- rep("paspreserver", length(motsnonpreserver))
motsnonatteindre <- c("pas attein*","atteint pas","pas maîtr*","ne maîtr*","pas passer","ne pass*","pas passé*",
"ne surmont*","pas surmont*","pas résou*","ne résou*","sans résolution","sans attein*",
"sans résolution","sans solution")
pasatteindre <- rep("pasatteindre", length(motsnonatteindre))
motsnonpossible <- c("non possible*","pas possible*","impossible","aucune possibilité","sans possibilité*",
"pas de potentiel","pas faisable*","non faisable","infaisable","non réalisable",
"pas réalisable","pas réaliser")
paspossible <- rep("paspossible", length(motsnonpossible))
parl_toks_fr <- parl_toks_fr %>%
tokens_replace(motspasdespoir, sansespoir) %>%
tokens_replace(motsnonpreserver, paspreserver) %>%
tokens_replace(motsnonatteindre, pasatteindre) %>%
tokens_replace(motsnonpossible, paspossible)
#Alle Tokens
parl_toks <- parl_toks %>%
tokens_replace(nohoffnungwords, keinehoffnung) %>%
tokens_replace(noconservewords, nichtbewahren) %>%
tokens_replace(nomeisternwords, nichtmeistern) %>%
tokens_replace(nomöglichwords, nichtmöglich) %>%
tokens_replace(motspasdespoir, sansespoir) %>%
tokens_replace(motsnonpreserver, paspreserver) %>%
tokens_replace(motsnonatteindre, pasatteindre) %>%
tokens_replace(motsnonpossible, paspossible)
Negative Wörter im Optimismus
#Deutsch
noprobwords <- c("unproblemat*","nicht problemat*","problemlos*","kein problem","keine probleme","kein ärger*",
"nicht ärger*","keine komplikation*","keiner schwer*","nicht erschwer*","keine schererei*",
"nicht schwierig*","keine schwierig*")
keinproblem <- rep("keinproblem", length(noprobwords))
nomisstrauwords <- c("nicht lüg*","keine lüg*","nicht gelog*","zutrauen","vertrauen","unbedenk*","zweifelsfrei",
"zweifelsohne","ohne zweifel","keine skepsis","unskeptisch*","ohne argwohn*",
"nicht argwöhn*","kein verdacht","ohne verdacht","nicht verdächt*","niemanden verdächt*")
keinmisstrauen <- rep("keinmisstrauen", length(nomisstrauwords))
parl_toks_de <- parl_toks_de %>%
tokens_replace(noprobwords, keinproblem) %>%
tokens_replace(nomisstrauwords, keinmisstrauen) %>%
tokens_replace("in angriff", "inangriff")
#'angriff' ist im Terror-Dictionary, während 'in Angriff nehmen' eine beliebte Wortkombination ist, die nichts mit Terror zu tun hat.
#Französisch
motssansprobleme <- c("pas de problème*","sans problème*","sans complication*","pas de complication*","pas dur*",
"pas aggravation*","pas de tracas","aucun problème","aucune complication","sans trouble*",
"pas de trouble","sans difficulté*","pas de difficulté*","aucune difficulté")
sansprobleme <- rep("sansprobleme", length(motssansprobleme))
motssansmefi <- c("sans méfiance*","aucun doute","sans doute","pas sceptique","pas menti","ne ment*",
"ne suspect*","aucun suspicion","pas de suspicion","pas de scepticisme")
sansmefiance <- rep("sansmefiance", length(motssansmefi))
parl_toks_fr <- parl_toks_fr %>%
tokens_replace(motssansprobleme, sansprobleme) %>%
tokens_replace(motssansmefi, sansmefiance) %>%
tokens_replace("aucun danger", "aucundanger")
parl_toks <- parl_toks %>%
tokens_replace(noprobwords, keinproblem) %>%
tokens_replace(nomisstrauwords, keinmisstrauen) %>%
tokens_replace(motssansprobleme, sansprobleme) %>%
tokens_replace(motssansmefi, sansmefiance) %>%
tokens_replace("aucun danger", "aucundanger")
Pessimismus Dictionary ohne Sub-Kategorien
#Anfangs habe ich Dictionaries mit Unterkategorien erstellt. Im Laufe des Codes habe ich bemerkt, dass mir das dann bei der Berechnung einen Strich durch die Rechnung macht. Ich habe die ursprünglichen Dictionaries gespeichert, verwende hier aber diejenigen ohne.
#Die Dictionaries mit Unterkategorien haben beim Optimierungsprozess geholfen, weil ich da kontrollieren konnte, ob die Unterscheidung nach Deutsch/Französisch funktioniert, und ob es mir ein deutsches Wort mit stemming unabsichtlich als französischen Wortstamm anwendet.
dictpess <- dictionary(list(pessimist = c("keinehoffnung","nichtmeistern","nichtmöglich","nichtbewahren",
"scheit*","untergehen","stolper*","strauchel*","versag*",
"auf der Strecke","fehlschlag*","fehlgeschlag*","danebenge*",
"misslingen","missgelungen","missglück*","verlier*","verlor*",
"verlust*","nichtohneverlust*","mangel*","nichtohnemangel*","schaden",
"nichtohneschaden","schäd*","schwund","nichtohneschwund","rückschlag",
"wegfall*","krise","ausweglos*","sackgasse","zwangslage","tiefstand",
"tiefpunkt","bedrängnis","klemme","misere","schlamassel","bredouille",
"notsituation*","notlage","notgedrungen","der not","die not",
"aus not","problemat*","problem*","ärger*","komplikation*",
"schererei*","gefahr*","gefähr*","bedroh*","drohend*","unheil",
"damoklesschwert","dunkel*","dunkl*","düster*","grau*","schwarz*",
"trist*","trostlos*","rabenschwarz*","finster*","stockdunkel",
"misstrau*","nichtvertrauen","nichtzutrauen","lüg*","gelogen*",
"nicht über den weg trauen","bedenk*","zweifel*","skepsis",
"skeptisch*","argwohn*","argwöhn*","verdacht","verdächt*",
"spanischvorkommen","nichtohneargwohn","nichtohneverdacht",
"pessimismus","pessimistisch","nichtoptimis*","keinoptimis*",
"endzeit*","schwer*","beschwerlich*","erschwer*","schwier*",
"überford*","verzweif*","pasatteindre","paspossible","sansespoir",
"paspreserver","irrécupérable","échou*","péri*","trébuch*",
"une fausse couche","malheur*","perte","perd","pénurie*",
"déficience*","dommage*","en baisse","recul*","crise","cul-de-sac",
"situation difficile","point bas","détresse","gâchis","misère",
"désordre","adversité","problèm*","problém*","trouble*",
"complication*","aggravation*","difficult*","danger*","menaçant*",
"menace*","imminent*","catastroph*","épée de damoclès","sombre*",
"gris*","noir*","morne*","noir absolu","méfi*",
"ne pas faire confiance","menti*","doute*",
"scepticisme","sceptique*","suspicion*","suspect*","pessimisme",
"pessimiste","fin des temps","difficile*","lourd*","fastidieu*",
"désespér*")))
Optimistisches Dictionary
dictopt <- dictionary(list(optimist = c("herausforderung*","herausgeford*","kampfansage","meistern","bestehen",
"überwinden","lösen","bewältigen","bodigen","erreich*","geschafft",
"schaffe*","lösung","hoffnung*","hoffen","hoffnungsvoll*","zuversicht*",
"chance*","möglich*","potential","potentiell*","machbar*","ausführbar*",
"praktikabel","besser","verbesser*","förder*","hell*","glänzend*",
"licht*","strahlend*","bessere zukunft","zukunft","morgen",
"gute aussicht*","perspektive*","bewahren","erhalten","retten",
"aufrechterhalten","schützen","keinproblem","keinmisstrauen",
"nichtpessimis*","keinpessimis*","optimistisch","optimismus","streben*",
"bestreb*","bemüh*","eifer","einsatz","nichtohneeinsatz","tatendrang",
"helfen*","hilfe","rettung","behilflich*","behelfs*","unterstütz*",
"ungefährlich","défi*","maîtr*","passer","passé*","surmont*","résoudre",
"cope","attein*","solution","espoir","plein espoir","pleine espoir",
"confiance", "confident*","possible*","possibilité*","potentiel",
"faisable*","réalisable","réaliser","amélior*","meilleur*","mieux",
"promouv*","promeu*","brillant*","lumière*","radieu*","avenir",
"futur","demain","de bonnes perspectives*","perspective*",
"préserv*","sauver","sauvé*","maintenir","maintien","entret*","protéger",
"protège*","sansprobleme","sansmefiance","pas pessimiste",
"pas de pessimisme","optimiste","optimisme",
"aspir*","efforc*","zèle","ferveur","engagement","non sans engagement",
"aide*","sauv*","coup de main","secour*","secur*","soutien*","soutenir",
"aucundanger")))
Terror Dictionary
dictterr <- dictionary(list(terrorist = c("anschlag","angriff*","angreif*","der amok*","ein amok*",
"bombenanschl*","anschläge","attentat*","attentäter*",
"bombenattentat*","angriff*","autobombe*","bombenexplosion",
"sprengstoff*","getötet*","umgebracht","ermordet","hingerichtet*",
"hinrichten","gewaltakt*","gewalttat","gewaltsam*","gewaltbereit*",
"tyrann*","blutig*","kaltblütig*","blut","blutbad","zerstör*",
"gemetzel","dschihad*","heiliger krieg*","heilige krieg*",
"religiöse kämpfer*","religiöser kämpfer","glaubenskrieg*",
"terror*","morddroh*","todesdroh*","gefährder*","täter*",
"scharfschütze","sprengen","gesprengt","detonation","detoniert*",
"menschenmasse","menschenansammlung","menschenmenge",
"menschenschar","menschentraube","pulk*","selbstmordattentäter*",
"selbstmordflugzeug","selbstmordmission","erweiterter suizid",
"erweiterter selbstmord","attentat à la bombe","un amok",
"assassinat","décès","décéd*","périt","périss*",
"périr*","tuer","tué*","éteint*","éteindre","crevé*","deuil","meurtr*",
"sanglant*","cruel*","destruction","effondrement","carnage","tuerie",
"détrui*","jihad","guerre de foi","guerrier de la foi",
"combattant réligieux","combattante réligieuse","militant*",
"belligérant*","lutteur*","terreur","terrorisme","terroristique*",
"menace de mort","agresseu*","coupable*","assassin*","attaquant*",
"offenseu*","assaillant*","foule","attroupement","une masse",
"la masse","troupeau","suicid*","attentat suicide",
"auteur un attentat suicide","kamikaze","avion-suicide")))
Klima Dictionary
dictclim <- dictionary(list(klimawandel = c("klimawandel*","klima*","erderwärmung","globale erwärmung",
"klimaerwärmung","umweltzerstörung","zerstörung der umwelt",
"menschengemacht*","treibhausgas*","treibhauseffekt*",
"ozon","kohlendioxid*","emission*","fossile brennstoffe",
"fossile treibstoffe","fossile energie","ipcc","weltklima*",
"kyoto protokoll","parisabkommen","abkommen von paris",
"pariser abkommen","energiehaushalt","energieverminderung",
"alternative energien","alternative energie*",
"erneuerbare energie*","solar*","photovoltaik*","fotovoltaik*",
"windräder","windrad","windenergie","wasserenergie","wasserkraft",
"neue technologien","neue energiequelle*","nachhaltig*",
"umweltverträglich*","klimaschutz","klimaschütz*",
"klimaverträglich*","klimajugend*","klimastreik*","biodiversität",
"fridays for future","artenschutz","artenvielfalt","bodenschutz",
"gewässerschutz","klimagerecht*","netto null",
"treibhausgasverminderung*","energiespar*",
"verminderungsmassnahm*","verminderungspflicht","food*",
"abfallvermeidung","plastikreduktion","plastik reduzier*",
"abfall reduzier*","bio*","energieeffizien*","recycling",
"rezyklier*","co2*","climat*","destruction de environnement",
"céé par homme","créés par homme","gaz à effet de serre",
"effet de serre","ozone","dioxyde","émission*",
"combustibles fossiles","énergie fossile","climat mondial","giec",
"protocole de kyoto","accord de paris",
"budget énergétique","consommation énergie",
"énergies alternatives","renouvelable*","solaire*","photovoltaïque*",
"turbines éoliennes","éolien*","eau énergie","hydroélectricité",
"nouvelles technologies","durabilité","durable*",
"protection de environnement","protection du climat",
"jeunesse climatique","biodiversité","protection espèces",
"protection des sols","net zéro","mesures de réduction",
"obligation de réduction","déchets alimentaires",
"protection de leau","prévention des déchets",
"réduction des plastiques","organique*","efficacité énergétique",
"recycl*","compensation carbone", "ges","empreinte carbone",
"ökologischer fussabdruck","écologique*","écologie","ökologisch")))
Document Features Matrix
parl_dfm <- parl_toks %>%
dfm() %>%
dfm_remove(pattern = stopwords('de')) %>%
dfm_remove(list(c("dass"))) %>%
dfm_remove(pattern = stopwords('fr'))
parl_dfm_de <- parl_toks_de %>%
dfm() %>%
dfm_remove(pattern = stopwords('de')) %>%
dfm_remove(list(c("dass")))
parl_dfm_fr <- parl_toks_fr %>%
dfm() %>%
dfm_remove(pattern = stopwords('fr'))
Dictionaries anwenden:
#Anwendung der Dictionaries auf die deutsche DFM
#Pessimismus:
dfm_pessD <- dfm_lookup(parl_dfm_de, dictpess, nomatch = "nomatch")
dfm_pessD_freq <- textstat_frequency(dfm_pessD, group = "year")
#Optimismus:
dfm_optD <- dfm_lookup(parl_dfm_de, dictopt, nomatch = "nomatch")
dfm_optD_freq <- textstat_frequency(dfm_optD, group = "year")
#Terror
dfm_terrD <- dfm_lookup(parl_dfm_de, dictterr, nomatch = "nomatch")
dfm_terrD_freq <- textstat_frequency(dfm_terrD, group = "year")
#Klima:
dfm_climD <- dfm_lookup(parl_dfm_de, dictclim, nomatch = "nomatch")
dfm_climD_freq <- textstat_frequency(dfm_climD, group = "year")
#Anwendung der Dictionaries auf die französische DFM
#Pessimismus
dfm_pessF <- dfm_lookup(parl_dfm_fr, dictpess, nomatch = "nomatch")
dfm_pessF_freq <- textstat_frequency(dfm_pessF, group = "year")
#Optimismus:
dfm_optF <- dfm_lookup(parl_dfm_fr, dictopt, nomatch = "nomatch")
dfm_optF_freq <- textstat_frequency(dfm_optF, group = "year")
#Terror
dfm_terrF <- dfm_lookup(parl_dfm_fr, dictterr, nomatch = "nomatch")
dfm_terrF_freq <- textstat_frequency(dfm_terrF, group = "year")
#Klima
dfm_climF <- dfm_lookup(parl_dfm_fr, dictclim, nomatch = "nomatch")
dfm_climF_freq <- textstat_frequency(dfm_climF, group = "year")
#Anwendung der Dictionaries auf die komplette DFM
#Pessimismus
dfm_pess <- dfm_lookup(parl_dfm, dictpess, nomatch = "nomatch")
dfm_pess_freq <- textstat_frequency(dfm_pess, group = "year")
#Optimismus:
dfm_opt <- dfm_lookup(parl_dfm, dictopt, nomatch = "nomatch")
dfm_opt_freq <- textstat_frequency(dfm_opt, group = "year")
#Terror
dfm_terr <- dfm_lookup(parl_dfm, dictterr, nomatch = "nomatch")
dfm_terr_freq <- textstat_frequency(dfm_terr, group = "year")
#Klima
dfm_clim <- dfm_lookup(parl_dfm, dictclim, nomatch = "nomatch")
dfm_clim_freq <- textstat_frequency(dfm_clim, group = "year")
Visualisierungen
Generelle Entwicklung von Pessimismus und Optimismus
gg_pess <- dfm_pess_freq %>%
group_by(group) %>%
mutate(sum = sum(docfreq)) %>%
mutate(pct = docfreq/sum*100)
gg_opt <- dfm_opt_freq %>%
group_by(group) %>%
mutate(sum = sum(docfreq)) %>%
mutate(pct = docfreq/sum*100)
pess <- ggplot(data = subset(gg_pess, feature != "nomatch"), mapping = aes(x = group, y = pct, group = 1)) +
geom_path(data = subset(gg_pess, feature != "nomatch"), mapping = aes(x = group, y = pct), color = rgb(204,0,0,150,maxColorValue=255), size = 1.5) +
theme_minimal() + theme(axis.text.x = element_text(size=rel(1), angle = 45, hjust = 1.5))
pess
pessopt <- pess + geom_path(data = subset(gg_opt, feature != "nomatch"), mapping = aes(x = group, y = pct), color = rgb(0,204,102,150,maxColorValue=255), size = 1.5) +
geom_curve(aes(x = "2017", y = 31, xend = "2015", yend = 29.5), color = "#69cf9c",
arrow = arrow(length = unit(0.03, "npc"))) +
geom_label(aes(x = "2015", y = 29, label = "Optimismus"), label.size = 0, color = "#69cf9c") +
geom_curve(aes(x = "2002", y = 27.5, xend = "2004", yend = 28.5), color = "#c94b4b", curvature = -0.5,
arrow = arrow(length = unit(0.03, "npc"))) +
geom_label(aes(x = "2005", y = 28.5, label = "Pessimismus"), label.size = 0, color = "#c94b4b") +
labs(title = "Im Schweizer Parlament regiert der Optimismus",
subtitle = "Relative Häufigkeit optimistischer/pessimistischer Wörter in Prozent",
caption = "Daten: Digital Democracy Lab") +
theme(plot.caption = element_text(face = "italic", vjust = -2)) +
ylab("Prozent") + xlab(element_blank())
pessopt
#ggsave("PessOpt_Gesamt_corr.jpg", pessopt, path = "~/1 UZH/MA 8_FS 21/Forschungsseminar Datenjournalismus/Blogbeitrag/Grafiken", width = 12, height = 7)
Wie hat sich die Klimadebatte verändert?
gg_klim <- dfm_clim_freq %>%
group_by(group) %>%
mutate(sum = sum(docfreq)) %>%
mutate(pct = docfreq/sum*100)
gg_klimD <- dfm_climD_freq %>%
group_by(group) %>%
mutate(sum = sum(docfreq)) %>%
mutate(pct = docfreq/sum*100)
gg_klimF <- dfm_climF_freq %>%
group_by(group) %>%
mutate(sum = sum(docfreq)) %>%
mutate(pct = docfreq/sum*100)
klima <- ggplot(data = subset(gg_klim, feature != "nomatch"), mapping = aes(x = group, y = pct, group = 1)) +
geom_path(data = subset(gg_klim, feature != "nomatch"), mapping = aes(x = group, y = pct), color = "#f2d113", size = 1.5) +
geom_ribbon(aes(ymin = 4, ymax = pct), fill = rgb(242, 235, 19,150, maxColorValue = 255)) +
geom_label(aes(x = "2003", y = 4.6, label = "Hitzesommer"), label.size = 0) +
geom_label(aes(x = "2010", y = 5.7, label = "Hitzesommer &\nÖlpest\nDeepwater Horizon"), label.size = 0) +
geom_label(aes(x = "2019", y = 4.6, label = "Fridays\nfor Future"), label.size = 0) +
geom_vline(aes(xintercept = "2003"), linetype = "dashed", color = "darkgray") +
geom_vline(aes(xintercept = "2010"), linetype = "dashed", color = "darkgray") +
geom_vline(aes(xintercept = "2019"), linetype = "dashed", color = "darkgray") +
labs(title = "Die Klimadebatte im Schweizer Parlament wird von externen Ereignissen angekurbelt",
subtitle = "Relative Häufigkeit der Klimawörter in Prozent",
caption = "Daten: Digital Democracy Lab") +
theme_minimal() +
theme(axis.text.x = element_text(size=rel(1), angle = 45, hjust = 1.5),
plot.caption = element_text(face = "italic", vjust = -2)) +
ylab("Prozent") + xlab(element_blank())
klima
#ggsave("Klima_Gesamt_corr.jpg", klima, path = "~/1 UZH/MA 8_FS 21/Forschungsseminar Datenjournalismus/Blogbeitrag/Grafiken", width = 12, height = 7)
#Klimadebatte dies- und jenseits vom Röstigraben:
klimaD <- ggplot(data = subset(gg_klimD, feature != "nomatch"), mapping = aes(x = group, y = pct, group = 1)) +
geom_path(color = rgb(240, 118, 43,255, maxColorValue = 255), size = 1.5) +
theme_minimal()
klimaFD <- klimaD + geom_path(data = subset(gg_klimF, feature != "nomatch"), mapping = aes(x = group, y = pct, group = 2), color = rgb(242, 194, 19,255, maxColorValue = 255), size = 1.5) +
theme(axis.text.x = element_text(size=rel(1), angle = 45, hjust = 1.5)) +
geom_label(aes(x = "2003", y = 9, label = "Hitzesommer"), label.size = 0) +
geom_label(aes(x = "2010", y = 6, label = "Hitzesommer &\nÖlpest\nDeepwater Horizon"), label.size = 0) +
geom_label(aes(x = "2019", y = 5, label = "Fridays\nfor Future"), label.size = 0) +
geom_vline(aes(xintercept = "2003"), linetype = "dashed", color = "darkgray") +
geom_vline(aes(xintercept = "2010"), linetype = "dashed", color = "darkgray") +
geom_vline(aes(xintercept = "2019"), linetype = "dashed", color = "darkgray") +
geom_curve(aes(x = "2013", y = 9.3, xend = "2014", yend = 9.5), color = "#f2c213", curvature = -0.5,
arrow = arrow(length = unit(0.03, "npc"))) +
geom_label(aes(x = "2015", y = 9.5, label = "Romandie"), label.size = 0, color = "#f2c213") +
geom_curve(aes(x = "2016", y = 5.9, xend = "2015", yend = 5.5), color = "#f0762b",
arrow = arrow(length = unit(0.03, "npc"))) +
geom_label(aes(x = "2015", y = 5.3, label = "Deutschschweiz"), color = "#f0762b", label.size = 0) +
labs(title = "Politiker der Romandie sprechen öfter über das Klima",
subtitle = "Relative Häufigkeit der Klimawörter in Prozent",
caption = "Daten: Digital Democracy Lab") +
theme_minimal() +
theme(axis.text.x = element_text(size=rel(1), angle = 45, hjust = 1.5),
plot.caption = element_text(face = "italic", vjust = -2)) +
ylab("Prozent") + xlab(element_blank())
klimaFD
#ggsave("Klima_Beide_corr.jpg", klimaFD, path = "~/1 UZH/MA 8_FS 21/Forschungsseminar Datenjournalismus/Blogbeitrag/Grafiken", width = 12, height = 7)
Wie hat sich die Terrordebatte verändert?
gg_terr <- dfm_terr_freq %>%
group_by(group) %>%
mutate(sum = sum(docfreq)) %>%
mutate(pct = docfreq/sum*100)
gg_terrF <- dfm_terrF_freq %>%
group_by(group) %>%
mutate(sum = sum(docfreq)) %>%
mutate(pct = docfreq/sum*100)
gg_terrD <- dfm_terrD_freq %>%
group_by(group) %>%
mutate(sum = sum(docfreq)) %>%
mutate(pct = docfreq/sum*100)
terror <- ggplot(data = subset(gg_terr, feature != "nomatch"), mapping = aes(x = group, y = pct, group = 1)) +
geom_path(color = rgb(0,0,153,255,maxColorValue=255), size = 1.5) +
geom_ribbon(aes(ymin = 1, ymax = pct), fill = rgb(0,0,153,150, maxColorValue = 255)) +
geom_vline(aes(xintercept = "2001"), linetype = "dashed", color = "darkgray") +
geom_vline(aes(xintercept = "2013"), linetype = "dashed", color = "darkgray") +
geom_vline(aes(xintercept = "2015"), linetype = "dashed", color = "darkgray") +
geom_label(aes(x = "2001", y = 2.5, label = "9/11"), label.size = 0) +
geom_label(aes(x = "2013", y = 1.5, label = "Anschlag\nBoston\nMarathon"), label.size = 0) +
geom_label(aes(x = "2015", y = 2.3, label = "Charlie\nHébdo"), label.size = 0) +
labs(title = "Von allen Attentaten hat 9/11 die Terrorismus-Debatte am meisten angekurbelt",
subtitle = "Relative Häufigkeit der Terrorismus-Wörter in Prozent",
caption = "Daten: Digital Democracy Lab") +
theme_minimal() +
theme(axis.text.x = element_text(size=rel(1), angle = 45, hjust = 1.5),
plot.caption = element_text(face = "italic", vjust = -2)) +
ylab("Prozent") + xlab(element_blank())
terror
#ggsave("Terror_Gesamt_corr.jpg", terror, path = "~/1 UZH/MA 8_FS 21/Forschungsseminar Datenjournalismus/Blogbeitrag/Grafiken", width = 12, height = 7)
terrorD <- ggplot(data = subset(gg_terrD, feature != "nomatch"), mapping = aes(x = group, y = pct, group = 1)) +
geom_path(data = subset(gg_terrD, feature != "nomatch"), mapping = aes(x = group, y = pct), color = rgb(0,0,153,255,maxColorValue=255), size = 1.5) + theme_minimal() + theme(axis.text.x = element_text(size=rel(1), angle = 45, hjust = 1.5))
terrorFD <- terrorD + geom_path(data = subset(gg_terrF, feature != "nomatch"), mapping = aes(x = group, y = pct, group = 2), color = rgb(0,0,153,50,maxColorValue=255), size = 1.5) + theme_minimal() + theme(axis.text.x = element_text(size=rel(1), angle = 45, hjust = 1.5)) +
geom_vline(aes(xintercept = "2001"), linetype = "dashed", color = "darkgray") +
geom_vline(aes(xintercept = "2015"), linetype = "dashed", color = "darkgray") +
geom_label(aes(x = "2001", y = 7, label = "9/11"), label.size = 0) +
geom_label(aes(x = "2015", y = 5.5, label = "Charlie\nHébdo"), label.size = 0) +
geom_vline(aes(xintercept = "2013"), linetype = "dashed", color = "darkgray") +
geom_label(aes(x = "2013", y = 6, label = "Anschlag\nBoston\nMarathon"), label.size = 0) +
labs(title = "Politiker der Romandie sprechen öfter über Terrorismus",
subtitle = "Relative Häufigkeit der Terrorismus-Wörter in Prozent",
caption = "Daten: Digital Democracy Lab") +
theme(plot.caption = element_text(face = "italic", vjust = -2)) +
ylab("Prozent") + xlab(element_blank()) +
geom_curve(aes(x = "2004", y = 5.9, xend = "2006", yend = 6.5), color = "#cfcffc", curvature = -0.5,
arrow = arrow(length = unit(0.03, "npc"))) +
geom_label(aes(x = "2007", y = 6.5, label = "Romandie"), label.size = 0, color = "#cfcffc") +
geom_curve(aes(x = "2002", y = 4, xend = "2004", yend = 4.3), color = "#000099", curvature = -0.5,
arrow = arrow(length = unit(0.03, "npc"))) +
geom_label(aes(x = "2005", y = 4.1, label = "Deutschschweiz"), label.size = 0, color = "#000099")
terrorFD
#ggsave("Terror_Beide_corr.jpg", terrorFD, path = "~/1 UZH/MA 8_FS 21/Forschungsseminar Datenjournalismus/Blogbeitrag/Grafiken", width = 12, height = 7)
Ähneln sich die Pessimismus-/Optimismus- und Terrorismus-/Klima-Trends bei den Romands?
#Pessimismus
gg_pessF <- dfm_pessF_freq %>%
group_by(group) %>%
mutate(sum = sum(docfreq)) %>%
mutate(pct = docfreq/sum*100)
terrorFpess <- ggplot(data = subset(gg_terrF, feature != "nomatch"), mapping = aes(x = group, y = pct, group = 1)) +
geom_path(color = rgb(0,0,153,50,maxColorValue=255), size = 1.5) + theme_classic() +
theme(axis.text.x = element_blank(),
axis.line.x = element_blank(),
axis.ticks.x = element_blank(),
axis.title.x = element_blank()) + ylab("%") +
labs(title = "Bei den Romands sind sich die Entwicklungen von Pessimismus Klimadebatte verblüffend ähnlich",
subtitle= "Gemeinsame Häufigkeit von Kima-, Terrorismus- und Pessimismus-Wörtern (Romandie)") +
geom_label(aes(x = "2000", y = 4, label = "Terrorismus"), label.size = 0, color = rgb(0,0,153,50,maxColorValue=255),
size = 3.5)
klimaF <- ggplot(data = subset(gg_klimF, feature != "nomatch"), mapping = aes(x = group, y = pct, group = 1)) +
geom_path(color = rgb(242, 194, 19,255, maxColorValue = 255), size = 1.5) + theme_classic() +
theme(axis.text.x = element_text(size=rel(1), angle = 45, hjust = 1.5),
axis.title.x = element_blank(),
plot.caption = element_text(face = "italic", vjust = -2.5)) + ylab("%") + labs(caption = "Daten: Digital Democracy Lab") +
geom_label(aes(x = "2000", y = 9, label = "Klima"), label.size = 0, color = rgb(242, 194, 19,255,maxColorValue=255),
size = 3.5)
pessF <- ggplot(data = subset(gg_pessF, feature != "nomatch"), mapping = aes(x = group, y = pct, group = 1)) +
geom_path(color = rgb(204,0,0,150,maxColorValue=255), size = 1.5) +
geom_path(color = rgb(204,0,0,150,255,maxColorValue=255), size = 1.5) + theme_classic() +
theme(axis.text.x = element_blank(),
axis.line.x = element_blank(),
axis.ticks.x = element_blank(),
axis.title.x = element_blank()) + ylab("%") +
geom_label(aes(x = "2000", y = 27, label = "Pessimismus"), label.size = 0, color = rgb(204,0,0,150,maxColorValue=255),
size = 3.5)
terrpessklimF <- ggarrange(terrorFpess, pessF, klimaF, nrow = 3, ncol = 1, align = c("v"))
terrpessklimF
#ggsave("1TerrKlim_PessF_corr.jpg", terrpessklimF, path = "~/1 UZH/MA 8_FS 21/Forschungsseminar Datenjournalismus/Blogbeitrag/Grafiken", width = 12, height = 7)
#Optimismus
gg_optF <- dfm_optF_freq %>%
group_by(group) %>%
mutate(sum = sum(docfreq)) %>%
mutate(pct = docfreq/sum*100)
terrorFopt <- ggplot(data = subset(gg_terrF, feature != "nomatch"), mapping = aes(x = group, y = pct, group = 1)) +
geom_path(color = rgb(0,0,153,50,maxColorValue=255), size = 1.5) + theme_classic() +
theme(axis.text.x = element_blank(),
axis.line.x = element_blank(),
axis.ticks.x = element_blank(),
axis.title.x = element_blank()) + ylab("%") +
labs(title = "Bei den Romands sind sich die Entwicklungen von Optimismus und Klimadebatte verblüffend ähnlich",
subtitle= "Gemeinsame Häufigkeit von Klima-, Terrorismus- und Optimismus-Wörtern (Romandie)") +
geom_label(aes(x = "2000", y = 4, label = "Terrorismus"), label.size = 0, color = rgb(0,0,153,50,maxColorValue=255),
size = 3.5)
optF <- ggplot(data = subset(gg_optF, feature != "nomatch"), mapping = aes(x = group, y = pct, group = 1)) + geom_path(color = rgb(0,204,102,150,maxColorValue=255), size = 1.5) + theme_classic() +
theme(axis.text.x = element_blank(),
axis.line.x = element_blank(),
axis.ticks.x = element_blank(),
axis.title.x = element_blank()) + ylab("%") +
geom_label(aes(x = "2000", y = 35, label = "Optimismus"), label.size = 0, color = rgb(0,204,102,150,maxColorValue=255),
size = 3.5)
terroptklimF <- ggarrange(terrorFopt, optF, klimaF, nrow = 3, ncol = 1, align = c("v"))
terroptklimF
#ggsave("2TerrKlim_OptF_corr.jpg", terroptklimF, path = "~/1 UZH/MA 8_FS 21/Forschungsseminar Datenjournalismus/Blogbeitrag/Grafiken", width = 12, height = 7)
Ähneln sich die Pessimismus-/Optimismus- und Terrorismus-/Klima-Trends bei den Deutschschweizern?
#Pessimismus
gg_pessD <- dfm_pessD_freq %>%
group_by(group) %>%
mutate(sum = sum(docfreq)) %>%
mutate(pct = docfreq/sum*100)
terrorDpess <- ggplot(data = subset(gg_terrD, feature != "nomatch"), mapping = aes(x = group, y = pct, group = 1)) +
geom_path(color = rgb(0,0,153,255,maxColorValue=255), size = 1.5) + theme_classic() +
theme(axis.text.x = element_blank(),
axis.line.x = element_blank(),
axis.ticks.x = element_blank(),
axis.title.x = element_blank()) + ylab("%") +
labs(title = "Bei den Deutschschweizern ähnelt der Pessimismus-Verlauf weder der Klima- noch der Terrordebatte",
subtitle= "Gemeinsame Häufigkeit von Kima-, Terrorismus- und Pessimismus-Wörtern (Deutschschweiz)") +
geom_label(aes(x = "2001", y = 2.9, label = "Terrorismus"), label.size = 0, color = rgb(0,0,153,255,maxColorValue=255),
size = 3.5)
klimaD <- ggplot(data = subset(gg_klimD, feature != "nomatch"), mapping = aes(x = group, y = pct, group = 1)) +
geom_path(color = rgb(240, 118, 43,255, maxColorValue = 255), size = 1.5) +
theme_classic() +
theme(axis.text.x = element_text(size=rel(1), angle = 45, hjust = 1.5),
axis.title.x = element_blank(),
plot.caption = element_text(face = "italic", vjust = -2)) + ylab("%") +
labs(caption = "Daten: Digital Democracy Lab") +
geom_label(aes(x = "2001", y = 7.5, label = "Klima"), label.size = 0, color = rgb(240, 118, 43,255,maxColorValue=255),
size = 3.5)
pessD <- ggplot(data = subset(gg_pessD, feature != "nomatch"), mapping = aes(x = group, y = pct, group = 1)) +
geom_path(color = rgb(204,0,0,150,maxColorValue=255), size = 1.5) + theme_classic() +
theme(axis.text.x = element_blank(),
axis.line.x = element_blank(),
axis.ticks.x = element_blank(),
axis.title.x = element_blank()) +
ylab("%") +
geom_label(aes(x = "2001", y = 25, label = "Pessimismus"), label.size = 0, color = rgb(204,0,0,150,maxColorValue=255),
size = 3.5)
terrpessklimD <- ggarrange(terrorDpess, pessD, klimaD, nrow = 3, ncol = 1, align = c("v"))
terrpessklimD
#ggsave("3TerrKlim_PessD_corr.jpg", terrpessklimD, path = "~/1 UZH/MA 8_FS 21/Forschungsseminar Datenjournalismus/Blogbeitrag/Grafiken", width = 12, height = 7)
#Optimismus
gg_optD<- dfm_optD_freq %>%
group_by(group) %>%
mutate(sum = sum(docfreq)) %>%
mutate(pct = docfreq/sum*100)
terrorDopt <- ggplot(data = subset(gg_terrD, feature != "nomatch"), mapping = aes(x = group, y = pct, group = 1)) +
geom_path(color = rgb(0,0,153,255,maxColorValue=255), size = 1.5) + theme_classic() +
theme(axis.text.x = element_blank(),
axis.line.x = element_blank(),
axis.ticks.x = element_blank(),
axis.title.x = element_blank()) + ylab("%") +
labs(title = "Bei den Deutschschweizern ähnelt der Optimismus-Verlauf weder der Klima- noch der Terrordebatte",
subtitle = "Gemeinsame Häufigkeit von Klima-, Terrorismus- und Optimismus-Wörtern (Deutschschweiz)") +
geom_label(aes(x = "2001", y = 2.9, label = "Terrorismus"), label.size = 0, color = rgb(0,0,153,255,maxColorValue=255),
size = 3.5)
optD <- ggplot(data = subset(gg_optD, feature != "nomatch"), mapping = aes(x = group, y = pct, group = 1)) + geom_path(color = rgb(0,204,102,150,maxColorValue=255), size = 1.5) + theme_classic() +
theme(axis.text.x = element_blank(),
axis.line.x = element_blank(),
axis.ticks.x = element_blank(),
axis.title.x = element_blank()) + ylab("%") +
geom_label(aes(x = "2001", y = 33.5, label = "Optimismus"), label.size = 0, color = rgb(0,204,102,150,maxColorValue=255),
size = 3.5)
terroptklimD <- ggarrange(terrorDopt, optD, klimaD, nrow = 3, ncol = 1, align = c("v"))
terroptklimD
#ggsave("4TerrKlim_OptD_corr.jpg", terroptklimD, path = "~/1 UZH/MA 8_FS 21/Forschungsseminar Datenjournalismus/Blogbeitrag/Grafiken", width = 12, height = 7)