# Übungen zu Episode IV #' /\ /\ #' { `---' } #' { O O } #' ~~> V <~~ #' \ \|/ / #' `-----'__ #' / \ `^\_ #' { }\ |\_\_ W #' | \_/ |/ / \_\_( ) #' \__/ /(_E \__/ #' ( / #' MM ########################### # Lücken-Skript # Füllen Sie die Kommentare und beschreiben Sie, was die jeweilige Operation macht. ########################### # ?? library(tidyverse) library(tidycomm) woj_befragung <- WoJ # ?? woj_befragung %>% describe() # ?? # Zusatzfrage: Was ist der Unterschied zur vorherigen Operation (describe)? str(woj_befragung) # ?? woj_befragung %>% ggplot(aes(x = employment)) + geom_bar() + facet_wrap(vars(reach)) + ggtitle(label = 'Beschäftigungsverhältnisse je Medienreichweite') # ?? woj_befragung %>% crosstab(employment, reach, chi_square = TRUE) # ?? woj_befragung %>% add_index(ethik_verstaendnis, ethics_1, ethics_2, ethics_3, ethics_4) %>% get_reliability() # ?? woj_befragung <- woj_befragung %>% bind_cols('sex' = c(rep('m', 612), rep('d', 4), rep('w', 584))) # ?? woj_befragung %>% correlate(trust_parliament, trust_politicians) ########################### # Code-Verständnis 2.0 # Der folgende Code enthält noch nicht gelernte Elemente. # Können Sie trotzdem beschreiben, was hier passiert? ########################### # ?? ?tab_frequencies woj_befragung %>% filter(country == 'UK') %>% tab_frequencies(reach) # ?? # Die "trust_"-Items fragen nach "how much you personally trust ___" (1 = gar nicht, 5 = vollständig). woj_befragung %>% filter(country == 'Germany') %>% select(country, trust_parliament, trust_government, trust_parties, trust_politicians) %>% pivot_longer(-country, names_to = 'Instanz', values_to = 'Vertrauen') %>% ggplot(aes(x = Instanz, y = Vertrauen)) + geom_boxplot() # ?? # Die "trust_"-Items fragen nach "how much you personally trust ___" (1 = gar nicht, 5 = vollständig). woj_befragung %>% select(country, trust_parliament, trust_government, trust_parties, trust_politicians) %>% pivot_longer(-country, names_to = 'Instanz', values_to = 'Vertrauen') %>% ggplot(aes(x = Instanz, y = Vertrauen)) + geom_violin() + facet_wrap(vars(country)) + theme(axis.text.x = element_text(angle = 45, hjust = 1)) # ?? woj_befragung %>% select(trust_parliament, trust_politicians) %>% ggplot(aes(x = trust_parliament, y = trust_politicians)) + geom_point(alpha = .02) + geom_smooth(method = 'lm', se = FALSE) ########################### # Code-Anpassungen # Kopieren Sie sich den Code so zusammen, dass er den Anforderungen gerecht wird. ########################### # Visualisierung von Boxplots der "trust_government" je "country". # Korrelation von "trust_government" mit einem Index über die vier Ethik-Items. # Kreuztabelle der Anzahl Befragter je "sex"-Ausprägung (Spalten) und "reach" (Zeilen) in Deutschland # Chi²-Test zur gerade erstellen Kreuztabelle.