library(tidyverse)
gul <- tga %>%
select(b01_num_r ,
b06_internal_fa_rev,
b04_rev,
b06_external_fa ,
a0406, c04_governmental_fa,
b05_turnout_frq_rev,
d01_conventional_fa,
d03_not_free_fa,
d01_news_frequency,
d0702,
d0701,
d0704,
d0703_rev
)
gul_s <- data.frame(scale(gul, center=T, scale=T))
gul_s <- gul_s %>%
mutate(
gul_politics = (
b01_num_r +
b04_rev +
b06_external_fa +
a0406 +
c04_governmental_fa +
b05_turnout_frq_rev +
b06_internal_fa_rev
) / 7
)
gul_s <- gul_s %>%
mutate (gul_media = (d01_conventional_fa +
d03_not_free_fa +
d01_news_frequency) / 3)
gul_s <- gul_s %>%
mutate (gul_science = (d0702 +
d0701 +
d0704 +
d0703_rev) / 4)
combine gul_s dataframe with original tga dataframe
gul_ss <- gul_s %>% select(gul_politics, gul_media, gul_science)
tga <- cbind(tga, gul_ss)
Graphs
dim_names <- c(
`gul_media` = "Trust in Media",
`gul_politics` = "Trust in Politics",
`gul_science` = "Trust in Science"
)
tga %>%
pivot_longer(
cols = starts_with("gul_"),
names_to = "dimension",
values_to = "score"
) %>%
ggplot(aes(score)) +
facet_wrap(~dimension, labeller = as_labeller(dim_names)) +
geom_histogram(aes(y = ..density..), alpha = .2, bins = 50)+
geom_density(color = "red") +
labs(title =" Gullible Trust According to Sub-Dimensions") +
firatheme::theme_fira()
## Warning: The dot-dot notation (`..density..`) was deprecated in ggplot2 3.4.0.
## ℹ Please use `after_stat(density)` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
## Warning: Removed 579 rows containing non-finite values (`stat_bin()`).
## Warning: Removed 579 rows containing non-finite values (`stat_density()`).
dim_names <- c(
`gul_media` = "Trust in Media",
`gul_politics` = "Trust in Politics",
`gul_science` = "Trust in Science"
)
tga %>%
pivot_longer(
cols = starts_with("gul_"),
names_to = "dimension",
values_to = "score"
) %>%
filter( c08_f == "chp_partisan" |
c08_f =="hdp_partisan" | c08_f == "iyi_partisan" |
c08_f == "mhp_partisan" | c08_f == "akp_partisan") %>%
ggplot(aes(score, c08_f)) +
geom_boxplot() +
facet_wrap(~dimension, labeller = as_labeller(dim_names)) +
labs(title = "Gullible Trust According to Partisanship", y="") +
firatheme::theme_fira()
## Warning: Removed 433 rows containing non-finite values (`stat_boxplot()`).
dim_names <- c(
`gul_media` = "Trust in Media",
`gul_politics` = "Trust in Politics",
`gul_science` = "Trust in Science"
)
tga %>%
pivot_longer(
cols = starts_with("gul_"),
names_to = "dimension",
values_to = "score"
) %>%
drop_na(ideology_f) %>%
ggplot(aes(score, ideology_f)) +
geom_boxplot() +
facet_wrap(~dimension, labeller = as_labeller(dim_names)) +
labs(title = "Gullible Trust According to Ideology", y="") +
firatheme::theme_fira()
## Warning: Removed 536 rows containing non-finite values (`stat_boxplot()`).