-
-
Save ryanburge/4fc0c8481fdfa6c6ef0b0b9238aa3a62 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(rio) | |
library(janitor) | |
pew <- import("E://data/atp106.sav") %>% as_tibble() %>% clean_names() | |
gg <- pew %>% | |
mutate(ev = f_born) %>% | |
mutate(rel = frcode(f_relig == 1 & ev == 1 ~ "Evangelical Protestant", | |
f_relig == 1 & ev == 2 ~ "Non-Evangelical Prot.", | |
f_relig == 2 ~ "Catholic", | |
f_relig == 3 | f_relig == 4 | f_relig == 5 | f_relig == 6 | f_relig == 7 | f_relig == 8 ~ "Other World Religions", | |
f_relig == 9 ~ "Atheist", | |
f_relig == 10 ~ "Agnostic", | |
f_relig == 12 ~ "Nothing in Particular")) %>% | |
mutate(live = ftrper_a_w106) %>% | |
mutate(live = frcode(live == 5 ~ "Not At All", | |
live == 4 ~ "A Little Bit", | |
live == 3 ~ "Somewhat", | |
live == 2 ~ "Mostly", | |
live == 1 ~ "Completely")) %>% | |
group_by(rel) %>% | |
ct(live, wt = weight_w106, show_na = FALSE) | |
gg %>% | |
filter(rel != "NA") %>% | |
mutate(lab = round(pct, 2)) %>% | |
ggplot(., aes(x = 1, y = pct, fill = fct_rev(live))) + | |
geom_col(color = "black") + | |
coord_flip() + | |
facet_wrap(~ rel, ncol =1, strip.position = "left") + | |
scale_fill_gdocs() + | |
theme_rb() + | |
theme(legend.position = "bottom") + | |
scale_y_continuous(labels = percent) + | |
theme(strip.text.y.left = element_text(angle=0, hjust = 1)) + | |
guides(fill = guide_legend(reverse=T, nrow = 1)) + | |
theme(axis.title.y=element_blank(), axis.text.y=element_blank(), axis.ticks.y=element_blank()) + | |
theme(panel.grid.minor.y=element_blank(), panel.grid.major.y=element_blank()) + | |
geom_text(aes(label = ifelse(pct >.05, paste0(lab*100, '%'), '')), position = position_stack(vjust = 0.5), size = 6, family = "font", color = "black") + | |
labs(x = "", y = "", title = "I want to live the best life I can right now and not worry too much about the future", caption = "@ryanburge + @religiondata\nData: Pew American Trends Panel 106") | |
save("live_best_life.png", wd = 9, ht =4) | |
gg <- pew %>% | |
mutate(ev = f_born) %>% | |
mutate(rel = frcode(f_relig == 1 & ev == 1 ~ "Evangelical Protestant", | |
f_relig == 1 & ev == 2 ~ "Non-Evangelical Prot.", | |
f_relig == 2 ~ "Catholic", | |
f_relig == 3 | f_relig == 4 | f_relig == 5 | f_relig == 6 | f_relig == 7 | f_relig == 8 ~ "Other World Religions", | |
f_relig == 9 ~ "Atheist", | |
f_relig == 10 ~ "Agnostic", | |
f_relig == 12 ~ "Nothing in Particular")) %>% | |
mutate(live = ftrper_b_w106) %>% | |
mutate(live = frcode(live == 5 ~ "Not At All", | |
live == 4 ~ "A Little Bit", | |
live == 3 ~ "Somewhat", | |
live == 2 ~ "Mostly", | |
live == 1 ~ "Completely")) %>% | |
group_by(rel) %>% | |
ct(live, wt = weight_w106, show_na = FALSE) | |
gg %>% | |
filter(rel != "NA") %>% | |
mutate(lab = round(pct, 2)) %>% | |
ggplot(., aes(x = 1, y = pct, fill = fct_rev(live))) + | |
geom_col(color = "black") + | |
coord_flip() + | |
facet_wrap(~ rel, ncol =1, strip.position = "left") + | |
scale_fill_gdocs() + | |
theme_rb() + | |
theme(legend.position = "bottom") + | |
scale_y_continuous(labels = percent) + | |
theme(strip.text.y.left = element_text(angle=0, hjust = 1)) + | |
guides(fill = guide_legend(reverse=T, nrow = 1)) + | |
theme(axis.title.y=element_blank(), axis.text.y=element_blank(), axis.ticks.y=element_blank()) + | |
theme(panel.grid.minor.y=element_blank(), panel.grid.major.y=element_blank()) + | |
geom_text(aes(label = ifelse(pct >.05, paste0(lab*100, '%'), '')), position = position_stack(vjust = 0.5), size = 6, family = "font", color = "black") + | |
labs(x = "", y = "", title = "I would be willing to make sacrifices in the way I live today if I knew it would help future generations", caption = "@ryanburge + @religiondata\nData: Pew American Trends Panel 106") | |
save("live_best_life2.png", wd = 9, ht =4) | |
pew %>% | |
mutate(ev = f_born) %>% | |
mutate(rel = frcode(f_relig == 1 & ev == 1 ~ "Evangelical Protestant", | |
f_relig == 1 & ev == 2 ~ "Non-Evangelical Prot.", | |
f_relig == 2 ~ "Catholic", | |
f_relig == 3 | f_relig == 4 | f_relig == 5 | f_relig == 6 | f_relig == 7 | f_relig == 8 ~ "Other World Religions", | |
f_relig == 9 ~ "Atheist", | |
f_relig == 10 ~ "Agnostic", | |
f_relig == 12 ~ "Nothing in Particular")) %>% | |
group_by(rel) %>% | |
mutate(val = case_when(species_w106 == 1 ~ 1, | |
species_w106 == 2 ~ 0)) %>% | |
mean_ci(val, wt = weight_w106, ci = .84) | |
pew %>% | |
mutate(ev = f_born) %>% | |
mutate(rel = frcode(f_relig == 1 & ev == 1 ~ "Evangelical Protestant", | |
f_relig == 1 & ev == 2 ~ "Non-Evangelical Prot.", | |
f_relig == 2 ~ "Catholic", | |
f_relig == 3 | f_relig == 4 | f_relig == 5 | f_relig == 6 | f_relig == 7 | f_relig == 8 ~ "Other World Religions", | |
f_relig == 9 ~ "Atheist", | |
f_relig == 10 ~ "Agnostic", | |
f_relig == 12 ~ "Nothing in Particular")) %>% | |
group_by(rel) %>% | |
mutate(val = case_when(sacredearth1_w106 == 1 ~ 1, | |
sacredearth1_w106 == 2 ~ 0)) %>% | |
mean_ci(val, wt = weight_w106, ci = .84) | |
gg <- pew %>% | |
mutate(ev = f_born) %>% | |
mutate(rel = frcode(f_relig == 1 & ev == 1 ~ "Evangelical Protestant", | |
f_relig == 1 & ev == 2 ~ "Non-Evangelical Prot.", | |
f_relig == 2 ~ "Catholic", | |
f_relig == 3 | f_relig == 4 | f_relig == 5 | f_relig == 6 | f_relig == 7 | f_relig == 8 ~ "Other World Religions", | |
f_relig == 9 ~ "Atheist", | |
f_relig == 10 ~ "Agnostic", | |
f_relig == 12 ~ "Nothing in Particular")) %>% | |
mutate(climate = clmsrs1_w106) %>% | |
mutate(climate = frcode(climate == 5 ~ "Not a Problem", | |
climate == 4 ~ "Not too Serious", | |
climate == 3 ~ "Somewhat Serious", | |
climate == 2 ~ "Very Serious", | |
climate == 1 ~ "Extremely Serious")) %>% | |
group_by(rel) %>% | |
ct(climate, wt = weight_w106, show_na = FALSE) | |
lvl <- gg %>% | |
filter(climate == "Extremely Serious") %>% | |
select(rel, sort = pct) | |
gg <- left_join(gg, lvl) | |
gg$rel <- fct_reorder(gg$rel, gg$sort, .desc = TRUE) | |
gg %>% | |
filter(rel != "NA") %>% | |
mutate(lab = round(pct, 2)) %>% | |
ggplot(., aes(x = 1, y = pct, fill = fct_rev(climate))) + | |
geom_col(color = "black") + | |
coord_flip() + | |
facet_wrap(~ rel, ncol =1, strip.position = "left") + | |
scale_fill_gdocs() + | |
theme_rb() + | |
theme(legend.position = "bottom") + | |
scale_y_continuous(labels = percent) + | |
theme(strip.text.y.left = element_text(angle=0, hjust = 1)) + | |
guides(fill = guide_legend(reverse=T, nrow = 1)) + | |
theme(axis.title.y=element_blank(), axis.text.y=element_blank(), axis.ticks.y=element_blank()) + | |
theme(panel.grid.minor.y=element_blank(), panel.grid.major.y=element_blank()) + | |
geom_text(aes(label = ifelse(pct >.05, paste0(lab*100, '%'), '')), position = position_stack(vjust = 0.5), size = 6, family = "font", color = "black") + | |
labs(x = "", y = "", title = "In your view, is global climate change a...", caption = "@ryanburge + @religiondata\nData: Pew American Trends Panel 106") | |
save("climate_change_problems.png", wd = 9, ht =4) | |
gg <- pew %>% | |
mutate(ev = f_born) %>% | |
mutate(rel = frcode(f_relig == 1 & ev == 1 ~ "Evangelical Protestant", | |
f_relig == 1 & ev == 2 ~ "Non-Evangelical Prot.", | |
f_relig == 2 ~ "Catholic", | |
f_relig == 3 | f_relig == 4 | f_relig == 5 | f_relig == 6 | f_relig == 7 | f_relig == 8 ~ "Other World Religions", | |
f_relig == 9 ~ "Atheist", | |
f_relig == 10 ~ "Agnostic", | |
f_relig == 12 ~ "Nothing in Particular")) %>% | |
mutate(pid3 = frcode(f_party_final == 2 ~ "Dem.", | |
f_party_final == 3 ~ "Ind.", | |
f_party_final == 1 ~ "Rep.")) %>% | |
mutate(climate = clmsrs1_w106) %>% | |
mutate(climate = case_when(climate == 1 | climate == 2 ~ 1, | |
climate == 3 | climate == 4 | climate == 5 ~ 0)) %>% | |
group_by(rel, pid3) %>% | |
mean_ci(climate, wt = weight_w106, ci = .84) %>% | |
filter(pid3 != "NA") | |
gg %>% | |
filter(rel != "NA") %>% | |
mutate(lab = round(mean, 2)) %>% | |
ggplot(., aes(x = pid3, y = mean, fill = pid3)) + | |
geom_col(color = "black") + | |
facet_wrap(~ rel, nrow = 2) + | |
pid3_fill() + | |
y_pct() + | |
theme_rb() + | |
error_bar() + | |
lab_bar(top = FALSE, type = lab, pos = .085, sz = 8) + | |
labs(x = "", y = "", title = "Share Saying Climate Change is an Extremely/Very Serious Problem", caption = "@ryanburge + @religiondata\nData: Pew American Trends Panel 106") | |
save("climate_change_pid3_rel.png") | |
gg <- pew %>% | |
mutate(ev = f_born) %>% | |
mutate(rel = frcode(f_relig == 1 & ev == 1 ~ "Evangelical Protestant", | |
f_relig == 1 & ev == 2 ~ "Non-Evangelical Prot.", | |
f_relig == 2 ~ "Catholic", | |
f_relig == 3 | f_relig == 4 | f_relig == 5 | f_relig == 6 | f_relig == 7 | f_relig == 8 ~ "Other World Religions", | |
f_relig == 9 ~ "Atheist", | |
f_relig == 10 ~ "Agnostic", | |
f_relig == 12 ~ "Nothing in Particular")) %>% | |
mutate(pid3 = frcode(f_party_final == 2 ~ "Dem.", | |
f_party_final == 3 ~ "Ind.", | |
f_party_final == 1 ~ "Rep.")) %>% | |
mutate(climate = clim1a_w106) %>% | |
mutate(climate = case_when(climate == 1 ~ 1, | |
climate == 2 | climate == 3 ~ 0)) %>% | |
group_by(rel, pid3) %>% | |
mean_ci(climate, wt = weight_w106, ci = .84) %>% | |
filter(pid3 != "NA") | |
gg %>% | |
filter(rel != "NA") %>% | |
mutate(lab = round(mean, 2)) %>% | |
ggplot(., aes(x = pid3, y = mean, fill = pid3)) + | |
geom_col(color = "black") + | |
facet_wrap(~ rel, nrow = 2) + | |
pid3_fill() + | |
y_pct() + | |
theme_rb() + | |
error_bar() + | |
geom_text(aes(y = .085, label = ifelse(mean < .99, paste0(lab*100, '%'), "")), position = position_dodge(width = .9), size = 8, family = "font") + | |
geom_text(aes(y = .085, label = ifelse(mean > .99, paste0(lab*100, '%'), "")), position = position_dodge(width = .9), size = 6, family = "font") + | |
labs(x = "", y = "", title = "The Earth is Getting Warmer Due to Human Activity Such as Burning Fossil Fuels", caption = "@ryanburge + @religiondata\nData: Pew American Trends Panel 106") | |
save("human_activity_pid3_rel.png") | |
gg <- pew %>% | |
mutate(ev = f_born) %>% | |
mutate(rel = frcode(f_relig == 1 & ev == 1 ~ "Evangelical Protestant", | |
f_relig == 1 & ev == 2 ~ "Non-Evangelical Prot.", | |
f_relig == 2 ~ "Catholic", | |
f_relig == 3 | f_relig == 4 | f_relig == 5 | f_relig == 6 | f_relig == 7 | f_relig == 8 ~ "Other World Religions")) %>% | |
mutate(pid3 = frcode(f_party_final == 2 ~ "Dem.", | |
f_party_final == 1 ~ "Rep.")) %>% | |
mutate(climate = humntr_a_w106) %>% | |
mutate(climate = frcode(climate == 5 ~ "Not At All", | |
climate == 4 ~ "A Little Bit", | |
climate == 3 ~ "Somewhat", | |
climate == 2 ~ "Mostly", | |
climate == 1 ~ "Completely")) %>% | |
group_by(rel, pid3) %>% | |
ct(climate, wt = weight_w106, show_na = FALSE) %>% | |
filter(pid3 != "NA") | |
gg %>% | |
filter(rel != "NA") %>% | |
mutate(lab = round(pct, 2)) %>% | |
ggplot(., aes(x = fct_rev(pid3), y = pct, fill = fct_rev(climate))) + | |
geom_col(color = "black") + | |
coord_flip() + | |
facet_wrap(~ rel, ncol =1, strip.position = "top") + | |
scale_fill_gdocs() + | |
theme_rb() + | |
theme(legend.position = "bottom") + | |
scale_y_continuous(labels = percent) + | |
theme(strip.text.y.left = element_text(angle=0, hjust = 1)) + | |
guides(fill = guide_legend(reverse=T, nrow = 1)) + | |
# theme(axis.title.y=element_blank(), axis.text.y=element_blank(), axis.ticks.y=element_blank()) + | |
theme(panel.grid.minor.y=element_blank(), panel.grid.major.y=element_blank()) + | |
theme(plot.title = element_text(size = 15)) + | |
theme(strip.text = element_text(size = 20)) + | |
geom_text(aes(label = ifelse(pct >.05, paste0(lab*100, '%'), '')), position = position_stack(vjust = 0.5), size = 6, family = "font", color = "black") + | |
labs(x = "", y = "", title = "God gave humans the right to use the Earth, including the plants and animals, for humanity's benefit", caption = "@ryanburge + @religiondata\nData: Pew American Trends Panel 106") | |
save("use_earth.png", wd = 9, ht =6) | |
gg <- pew %>% | |
mutate(ev = f_born) %>% | |
mutate(rel = frcode(f_relig == 1 & ev == 1 ~ "Evangelical Protestant", | |
f_relig == 1 & ev == 2 ~ "Non-Evangelical Prot.", | |
f_relig == 2 ~ "Catholic", | |
f_relig == 3 | f_relig == 4 | f_relig == 5 | f_relig == 6 | f_relig == 7 | f_relig == 8 ~ "Other World Religions")) %>% | |
mutate(pid3 = frcode(f_party_final == 2 ~ "Dem.", | |
f_party_final == 1 ~ "Rep.")) %>% | |
mutate(climate = humntr_b_w106) %>% | |
mutate(climate = frcode(climate == 5 ~ "Not At All", | |
climate == 4 ~ "A Little Bit", | |
climate == 3 ~ "Somewhat", | |
climate == 2 ~ "Mostly", | |
climate == 1 ~ "Completely")) %>% | |
group_by(rel, pid3) %>% | |
ct(climate, wt = weight_w106, show_na = FALSE) %>% | |
filter(pid3 != "NA") | |
gg %>% | |
filter(rel != "NA") %>% | |
mutate(lab = round(pct, 2)) %>% | |
ggplot(., aes(x = fct_rev(pid3), y = pct, fill = fct_rev(climate))) + | |
geom_col(color = "black") + | |
coord_flip() + | |
facet_wrap(~ rel, ncol =1, strip.position = "top") + | |
scale_fill_gdocs() + | |
theme_rb() + | |
theme(legend.position = "bottom") + | |
scale_y_continuous(labels = percent) + | |
theme(strip.text.y.left = element_text(angle=0, hjust = 1)) + | |
guides(fill = guide_legend(reverse=T, nrow = 1)) + | |
# theme(axis.title.y=element_blank(), axis.text.y=element_blank(), axis.ticks.y=element_blank()) + | |
theme(panel.grid.minor.y=element_blank(), panel.grid.major.y=element_blank()) + | |
theme(plot.title = element_text(size = 15)) + | |
theme(strip.text = element_text(size = 20)) + | |
geom_text(aes(label = ifelse(pct >.05, paste0(lab*100, '%'), '')), position = position_stack(vjust = 0.5), size = 6, family = "font", color = "black") + | |
labs(x = "", y = "", title = "God gave humans a duty to protect and care for the Earth, including the plants and animals", caption = "@ryanburge + @religiondata\nData: Pew American Trends Panel 106") | |
save("protect_earth.png", wd = 9, ht =6) | |
gg1 <- pew %>% | |
mutate(ev = f_born) %>% | |
mutate(rel = frcode(f_relig == 1 & ev == 1 ~ "Evangelical Protestant", | |
f_relig == 1 & ev == 2 ~ "Non-Evangelical Prot.", | |
f_relig == 2 ~ "Catholic", | |
f_relig == 3 | f_relig == 4 | f_relig == 5 | f_relig == 6 | f_relig == 7 | f_relig == 8 ~ "Other World Religions", | |
f_relig == 9 ~ "Atheist", | |
f_relig == 10 ~ "Agnostic", | |
f_relig == 12 ~ "Nothing in Particular")) %>% | |
mutate(pid3 = frcode(f_party_final == 2 ~ "Dem.", | |
f_party_final == 3 ~ "Ind.", | |
f_party_final == 1 ~ "Rep.")) %>% | |
mutate(climate = clmsrs1_w106) %>% | |
mutate(climate = case_when(climate == 1 | climate == 2 ~ 1, | |
climate == 3 | climate == 4 | climate == 5 ~ 0)) %>% | |
mutate(age4 = f_agecat) %>% | |
mutate(age4 = frcode(age4 == 1 ~ "18-29", | |
age4 == 2 ~ "30-49", | |
age4 == 3 ~ "50-64", | |
age4 == 4 ~ "65+")) %>% | |
group_by(rel, age4) %>% | |
mean_ci(climate, wt = weight_w106, ci = .84) %>% filter(age4 != "NA") | |
gg2 <- pew %>% | |
mutate(ev = f_born) %>% | |
mutate(rel = frcode(f_relig == 1 & ev == 1 ~ "Evangelical Protestant", | |
f_relig == 1 & ev == 2 ~ "Non-Evangelical Prot.", | |
f_relig == 2 ~ "Catholic", | |
f_relig == 3 | f_relig == 4 | f_relig == 5 | f_relig == 6 | f_relig == 7 | f_relig == 8 ~ "Other World Religions", | |
f_relig == 9 ~ "Atheist", | |
f_relig == 10 ~ "Agnostic", | |
f_relig == 12 ~ "Nothing in Particular")) %>% | |
mutate(pid3 = frcode(f_party_final == 2 ~ "Dem.", | |
f_party_final == 3 ~ "Ind.", | |
f_party_final == 1 ~ "Rep.")) %>% | |
mutate(climate = clmsrs1_w106) %>% | |
mutate(climate = case_when(climate == 1 | climate == 2 ~ 1, | |
climate == 3 | climate == 4 | climate == 5 ~ 0)) %>% | |
mutate(age4 = f_agecat) %>% | |
mutate(age4 = frcode(age4 == 1 ~ "18-29", | |
age4 == 2 ~ "30-49", | |
age4 == 3 ~ "50-64", | |
age4 == 4 ~ "65+")) %>% | |
group_by(age4) %>% | |
mean_ci(climate, wt = weight_w106, ci = .84) %>% filter(age4 != "NA") %>% | |
mutate(rel = "Entire Sample") | |
gg <- bind_rows(gg1, gg2) | |
gg$rel <- factor(gg$rel, levels = c("Entire Sample", "Evangelical Protestant", "Non-Evangelical Prot.", "Catholic", "Other World Religions", "Atheist", "Agnostic", "Nothing in Particular")) | |
gg %>% | |
filter(rel != "NA") %>% | |
mutate(lab = round(mean, 2)) %>% | |
ggplot(., aes(x = age4, y = mean, fill = age4)) + | |
geom_col(color = "black") + | |
facet_wrap(~ rel, nrow = 2) + | |
scale_fill_gdocs() + | |
y_pct() + | |
theme_rb() + | |
error_bar() + | |
lab_bar(top = FALSE, type = lab, pos = .085, sz = 6) + | |
labs(x = "", y = "", title = "Share Saying Climate Change is an Extremely/Very Serious Problem", caption = "@ryanburge + @religiondata\nData: Pew American Trends Panel 106") | |
save("climate_change_age4_rel.png") | |
gg1 <- pew %>% | |
filter(f_born == 1 & f_relig == 1) %>% | |
filter(f_party_final == 1) %>% | |
mutate(age4 = f_agecat) %>% | |
mutate(age4 = frcode(age4 == 1 ~ "18-29", | |
age4 == 2 ~ "30-49", | |
age4 == 3 ~ "50-64", | |
age4 == 4 ~ "65+")) %>% | |
mutate(climate = clim1a_w106) %>% | |
mutate(climate = frcode(climate == 1 ~ "Mostly Human Activity", | |
climate == 2 ~ "Natural Weather Patterns", | |
climate == 3 ~ "No Evidence of Warming", | |
climate == 8 ~ "Not Sure")) %>% | |
group_by(age4) %>% | |
ct(climate, wt = weight_w106, show_na = FALSE) %>% na.omit() %>% | |
mutate(grp = "Evangelical Republicans") | |
gg2 <- pew %>% | |
filter(f_party_final == 1) %>% | |
mutate(age4 = f_agecat) %>% | |
mutate(age4 = frcode(age4 == 1 ~ "18-29", | |
age4 == 2 ~ "30-49", | |
age4 == 3 ~ "50-64", | |
age4 == 4 ~ "65+")) %>% | |
mutate(climate = clim1a_w106) %>% | |
mutate(climate = frcode(climate == 1 ~ "Mostly Human Activity", | |
climate == 2 ~ "Natural Weather Patterns", | |
climate == 3 ~ "No Evidence of Warming", | |
climate == 8 ~ "Not Sure")) %>% | |
group_by(age4) %>% | |
ct(climate, wt = weight_w106, show_na = FALSE) %>% na.omit() %>% | |
mutate(grp = "All Republicans") | |
gg3 <- pew %>% | |
mutate(age4 = f_agecat) %>% | |
mutate(age4 = frcode(age4 == 1 ~ "18-29", | |
age4 == 2 ~ "30-49", | |
age4 == 3 ~ "50-64", | |
age4 == 4 ~ "65+")) %>% | |
mutate(climate = clim1a_w106) %>% | |
mutate(climate = frcode(climate == 1 ~ "Mostly Human Activity", | |
climate == 2 ~ "Natural Weather Patterns", | |
climate == 3 ~ "No Evidence of Warming", | |
climate == 8 ~ "Not Sure")) %>% | |
group_by(age4) %>% | |
ct(climate, wt = weight_w106, show_na = FALSE) %>% na.omit() %>% | |
mutate(grp = "Entire Sample") | |
gg4 <- pew %>% | |
filter(f_party_final == 2) %>% | |
mutate(age4 = f_agecat) %>% | |
mutate(age4 = frcode(age4 == 1 ~ "18-29", | |
age4 == 2 ~ "30-49", | |
age4 == 3 ~ "50-64", | |
age4 == 4 ~ "65+")) %>% | |
mutate(climate = clim1a_w106) %>% | |
mutate(climate = frcode(climate == 1 ~ "Mostly Human Activity", | |
climate == 2 ~ "Natural Weather Patterns", | |
climate == 3 ~ "No Evidence of Warming", | |
climate == 8 ~ "Not Sure")) %>% | |
group_by(age4) %>% | |
ct(climate, wt = weight_w106, show_na = FALSE) %>% na.omit() %>% | |
mutate(grp = "All Democrats") | |
all <- bind_rows(gg1, gg2, gg3, gg4) | |
all$grp <- factor(all$grp, levels = c("Entire Sample", "All Democrats", "All Republicans", "Evangelical Republicans")) | |
all %>% | |
mutate(lab = round(pct, 2)) %>% | |
ggplot(., aes(x = fct_rev(grp), y = pct, fill = fct_rev(climate))) + | |
geom_col(color = "black") + | |
coord_flip() + | |
facet_wrap(~ age4, ncol =1, strip.position = "top") + | |
scale_fill_gdocs() + | |
theme_rb() + | |
theme(legend.position = "bottom") + | |
scale_y_continuous(labels = percent) + | |
theme(strip.text.y.left = element_text(angle=0, hjust = 1)) + | |
guides(fill = guide_legend(reverse=T, nrow = 1)) + | |
# theme(axis.title.y=element_blank(), axis.text.y=element_blank(), axis.ticks.y=element_blank()) + | |
theme(panel.grid.minor.y=element_blank(), panel.grid.major.y=element_blank()) + | |
theme(plot.title = element_text(size = 13)) + | |
theme(strip.text = element_text(size = 20)) + | |
geom_text(aes(label = ifelse(pct >.05, paste0(lab*100, '%'), '')), position = position_stack(vjust = 0.5), size = 6, family = "font", color = "black") + | |
labs(x = "", y = "", title = "Which of these three statements about the Earth's temperature comes closest to your view?", caption = "@ryanburge + @religiondata\nData: Pew American Trends Panel 106") | |
save("views_warming_age4_grps.png", wd = 9, ht =8) | |
gg1 <- pew %>% | |
filter(f_born == 1 & f_relig == 1) %>% | |
mutate(age4 = f_agecat) %>% | |
mutate(age4 = frcode(age4 == 1 ~ "18-29", | |
age4 == 2 ~ "30-49", | |
age4 == 3 ~ "50-64", | |
age4 == 4 ~ "65+")) %>% | |
group_by(age4) %>% | |
mutate(future = case_when(ftrper_a_w106 == 1 | ftrper_a_w106 == 2 ~ 1, | |
ftrper_a_w106 == 3 | ftrper_a_w106 == 3 | ftrper_a_w106 == 5 ~ 0)) %>% | |
mean_ci(future, wt = weight_w106, ci = .84) %>% na.omit() %>% | |
mutate(grp = "Evangelical Republicans") | |
graph <- pew %>% | |
mutate(ev = f_born) %>% | |
mutate(rel = frcode(f_relig == 1 & ev == 1 ~ "Evangelical Protestant", | |
f_relig == 1 & ev == 2 ~ "Non-Evangelical Prot.", | |
f_relig == 2 ~ "Catholic", | |
f_relig == 3 | f_relig == 4 | f_relig == 5 | f_relig == 6 | f_relig == 7 | f_relig == 8 ~ "Other World Religions")) %>% | |
mutate(sermon = sermonclm_w106) %>% | |
mutate(sermon = frcode(sermon == 5 ~ "None", | |
sermon == 4 ~ "A Little", | |
sermon == 3 ~ "Some", | |
sermon == 2 | sermon == 1 ~ "Quite a bit/Great Deal")) %>% | |
group_by(rel) %>% | |
ct(sermon, wt = weight_w106, show_na = FALSE) %>% | |
na.omit() | |
graph %>% | |
mutate(lab = round(pct, 2)) %>% | |
ggplot(., aes(x = 1, y = pct, fill = fct_rev(sermon))) + | |
geom_col(color = "black") + | |
coord_flip() + | |
facet_wrap(~ rel, ncol =1, strip.position = "left") + | |
scale_fill_gdocs() + | |
theme_rb() + | |
theme(legend.position = "bottom") + | |
scale_y_continuous(labels = percent) + | |
theme(strip.text.y.left = element_text(angle=0, hjust = 1)) + | |
guides(fill = guide_legend(reverse=T, nrow = 1)) + | |
theme(axis.title.y=element_blank(), axis.text.y=element_blank(), axis.ticks.y=element_blank()) + | |
theme(panel.grid.minor.y=element_blank(), panel.grid.major.y=element_blank()) + | |
theme(plot.title = element_text(size = 13)) + | |
# theme(strip.text = element_text(size = 20)) + | |
geom_text(aes(label = ifelse(pct >.05, paste0(lab*100, '%'), '')), position = position_stack(vjust = 0.5), size = 6, family = "font", color = "black") + | |
labs(x = "", y = "", title = "How much discussion of climate change is there in sermons at your house of worship?", caption = "@ryanburge + @religiondata\nData: Pew American Trends Panel 106") | |
save("sermons_climate.png", wd = 9, ht =3.5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment