-
-
Save ryanburge/79a0f0dd0b8696529b1123bb6cd63418 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| gg1 <- gss %>% | |
| filter(year <= 2018) %>% | |
| mutate(porn = pornlaw) %>% | |
| mutate(porn = frcode(porn == 1 ~ "Complete Ban", | |
| porn == 2 ~ "Ban for Minors", | |
| porn == 3 ~ "No Ban")) %>% | |
| group_by(year) %>% | |
| ct(porn, wt = wtssall, show_na = FALSE) | |
| gg2 <- gss %>% | |
| filter(year > 2018) %>% | |
| mutate(porn = pornlaw) %>% | |
| mutate(porn = frcode(porn == 1 ~ "Complete Ban", | |
| porn == 2 ~ "Ban for Minors", | |
| porn == 3 ~ "No Ban")) %>% | |
| group_by(year) %>% | |
| ct(porn, wt = wtssnrps, show_na = FALSE) | |
| gg <- bind_rows(gg1, gg2) | |
| gg %>% | |
| ggplot(., aes(x = year, y = pct, color = porn, group = porn)) + | |
| geom_point(stroke = .65, shape = 21) + | |
| geom_labelsmooth(aes(label = porn), method = "loess", formula = y ~ x, family = "font", linewidth = 1, text_smoothing = 30, size = 7, linewidth = 1, boxlinewidth = 0.3) + | |
| theme_rb() + | |
| y_pct() + | |
| add_text(x = 1973, y = .52, word = "49%", sz = 6) + | |
| add_text(x = 1973, y = .44, word = "42%", sz = 6) + | |
| add_text(x = 1973, y = .13, word = "10%", sz = 6) + | |
| add_text(x = 2022, y = .30, word = "28%", sz = 6) + | |
| add_text(x = 2022, y = .70, word = "68%", sz = 6) + | |
| add_text(x = 2022, y = .08, word = "4%", sz = 6) + | |
| scale_color_manual(values = c("#28666e", "#5f2680", "#B5B682", "azure4", "#7D3C98", "#5f2680", "#033f63", "#28666e", "#e1e1e1", "#B5B682", "#FEDC97", "#7D3C98", "#5f2680")) + | |
| labs(x = "", y = "", title = "Which of these statements comes closest to your feelings about pornography laws?", caption = "@ryanburge + @religiondata\nData: General Social Survey, 1973-2022") | |
| save("gss_porn_law.png") | |
| gg1 <- gss %>% | |
| mutate(gender = frcode(sex == 1 ~ "Men", | |
| sex == 2 ~ "Women")) %>% | |
| filter(year <= 2018) %>% | |
| mutate(porn = pornlaw) %>% | |
| mutate(porn = frcode(porn == 1 ~ "Complete Ban", | |
| porn == 2 ~ "Ban for Minors", | |
| porn == 3 ~ "No Ban")) %>% | |
| group_by(year, gender) %>% | |
| ct(porn, wt = wtssall, show_na = FALSE) | |
| gg2 <- gss %>% | |
| mutate(gender = frcode(sex == 1 ~ "Men", | |
| sex == 2 ~ "Women")) %>% | |
| filter(year > 2018) %>% | |
| mutate(porn = pornlaw) %>% | |
| mutate(porn = frcode(porn == 1 ~ "Complete Ban", | |
| porn == 2 ~ "Ban for Minors", | |
| porn == 3 ~ "No Ban")) %>% | |
| group_by(year, gender) %>% | |
| ct(porn, wt = wtssnrps, show_na = FALSE) | |
| gg <- bind_rows(gg1, gg2) %>% filter(gender != "NA") | |
| gg %>% | |
| ggplot(., aes(x = year, y = pct, color = gender, group = gender)) + | |
| geom_point(stroke = .25, shape = 21, alpha = .5) + | |
| geom_smooth(se= FALSE) + | |
| facet_wrap(~ porn) + | |
| scale_y_continuous(labels = percent) + | |
| scale_color_manual(values = c("#B5B682", "#5f2680")) + | |
| theme_rb(legend = TRUE) + | |
| labs(x = "", y = "", title = "Which of these statements comes closest to your feelings about pornography laws?", caption = "@ryanburge + @religiondata\nData: General Social Survey, 1973-2022") | |
| save("porn_law_gender.png") | |
| gg1 <- gss %>% | |
| filter(year <= 2018) %>% | |
| gss_reltrad6(reltrad) %>% | |
| mutate(porn = pornlaw) %>% | |
| mutate(porn = frcode(porn == 1 ~ "Complete Ban", | |
| porn == 2 ~ "Ban for Minors", | |
| porn == 3 ~ "No Ban")) %>% | |
| group_by(reltrad, year) %>% | |
| ct(porn, wt = wtssall, show_na = FALSE) | |
| gg2 <- gss %>% | |
| filter(year > 2018) %>% | |
| gss_reltrad6(reltrad) %>% | |
| mutate(porn = pornlaw) %>% | |
| mutate(porn = frcode(porn == 1 ~ "Complete Ban", | |
| porn == 2 ~ "Ban for Minors", | |
| porn == 3 ~ "No Ban")) %>% | |
| group_by(reltrad, year) %>% | |
| ct(porn, wt = wtssnrps, show_na = FALSE) | |
| gg <- bind_rows(gg1, gg2) %>% filter(reltrad != "NA") %>% na.omit() | |
| gg %>% | |
| ggplot(., aes(x = year, y = pct, color = porn, group = porn)) + | |
| geom_point(stroke = .25, shape = 21) + | |
| geom_smooth(se = FALSE) + | |
| facet_wrap(~ reltrad) + | |
| scale_color_manual(values = c("#28666e", "#5f2680", "#B5B682", "azure4", "#7D3C98", "#5f2680", "#033f63", "#28666e", "#e1e1e1", "#B5B682", "#FEDC97", "#7D3C98", "#5f2680")) + | |
| theme_rb(legend = TRUE) + | |
| y_pct() + | |
| theme(strip.text = element_text(size = 20)) + | |
| labs(x = "", y = "", title = "Which of these statements comes closest to your feelings about pornography laws?", caption = "@ryanburge + @religiondata\nData: General Social Survey, 1973-2022") | |
| save("porn_law_reltrad.png", ht = 9) | |
| gg1 <- gss %>% | |
| filter(year <= 2018) %>% | |
| mutate(birthyr = year - age) %>% | |
| mutate(cohorts = frcode(birthyr >= 1940 & birthyr <= 1944 ~ "1940-1944", | |
| birthyr >= 1945 & birthyr <= 1949 ~ "1945-1949", | |
| birthyr >= 1950 & birthyr <= 1954 ~ "1950-1954", | |
| birthyr >= 1955 & birthyr <= 1959 ~ "1955-1959", | |
| birthyr >= 1960 & birthyr <= 1964 ~ "1960-1964", | |
| birthyr >= 1965 & birthyr <= 1969 ~ "1965-1969", | |
| birthyr >= 1970 & birthyr <= 1974 ~ "1970-1974", | |
| birthyr >= 1975 & birthyr <= 1979 ~ "1975-1979", | |
| birthyr >= 1980 & birthyr <= 1984 ~ "1980-1984", | |
| birthyr >= 1985 & birthyr <= 1989 ~ "1985-1989", | |
| birthyr >= 1990 & birthyr <= 1994 ~ "1990-1994", | |
| birthyr >= 1995 & birthyr <= 2000 ~ "1995-2000")) %>% | |
| mutate(porn = pornlaw) %>% | |
| mutate(porn = frcode(porn == 1 ~ "Complete Ban", | |
| porn == 2 ~ "Ban for Minors", | |
| porn == 3 ~ "No Ban")) %>% | |
| group_by(cohorts, year) %>% | |
| ct(porn, wt = wtssall, show_na = FALSE) | |
| gg2 <- gss %>% | |
| filter(year > 2018) %>% | |
| mutate(birthyr = year - age) %>% | |
| mutate(cohorts = frcode(birthyr >= 1940 & birthyr <= 1944 ~ "1940-1944", | |
| birthyr >= 1945 & birthyr <= 1949 ~ "1945-1949", | |
| birthyr >= 1950 & birthyr <= 1954 ~ "1950-1954", | |
| birthyr >= 1955 & birthyr <= 1959 ~ "1955-1959", | |
| birthyr >= 1960 & birthyr <= 1964 ~ "1960-1964", | |
| birthyr >= 1965 & birthyr <= 1969 ~ "1965-1969", | |
| birthyr >= 1970 & birthyr <= 1974 ~ "1970-1974", | |
| birthyr >= 1975 & birthyr <= 1979 ~ "1975-1979", | |
| birthyr >= 1980 & birthyr <= 1984 ~ "1980-1984", | |
| birthyr >= 1985 & birthyr <= 1989 ~ "1985-1989", | |
| birthyr >= 1990 & birthyr <= 1994 ~ "1990-1994", | |
| birthyr >= 1995 & birthyr <= 2000 ~ "1995-2000")) %>% | |
| mutate(porn = pornlaw) %>% | |
| mutate(porn = frcode(porn == 1 ~ "Complete Ban", | |
| porn == 2 ~ "Ban for Minors", | |
| porn == 3 ~ "No Ban")) %>% | |
| group_by(cohorts, year) %>% | |
| ct(porn, wt = wtssnrps, show_na = FALSE) | |
| all <- bind_rows(gg1, gg2) %>% | |
| filter(cohorts != "NA") | |
| all <- all[!(all$cohorts == "1995-2000" & all$year == 2014), ] | |
| all %>% | |
| ggplot(., aes(x = year, y = pct, color = porn, group = porn)) + | |
| geom_point(stroke = .15, shape = 21, alpha = 1) + | |
| geom_smooth(se = FALSE) + | |
| facet_wrap(~ cohorts) + | |
| scale_color_manual(values = c("#28666e", "#5f2680", "#B5B682", "azure4", "#7D3C98", "#5f2680", "#033f63", "#28666e", "#e1e1e1", "#B5B682", "#FEDC97", "#7D3C98", "#5f2680")) + | |
| theme_rb(legend = TRUE) + | |
| y_pct() + | |
| labs(x = "", y = "", title = "Which of these statements comes closest to your feelings about pornography laws?", caption = "@ryanburge + @religiondata\nData: General Social Survey, 1973-2022") | |
| save("porn_law_birth_cohort.png", ht = 12) | |
| regg <- gss %>% | |
| filter(year >= 2020) %>% | |
| mutate(porn = pornlaw) %>% | |
| mutate(porn = case_when(porn == 1 ~ 1, | |
| porn == 2 | porn == 3 ~ 0)) %>% | |
| mutate(white = case_when(race == 1 ~ 1, | |
| TRUE ~ 0)) %>% | |
| mutate(male = case_when(sex == 1 ~ 1, | |
| sex == 2 ~ 0)) %>% | |
| mutate(rep = case_when(partyid == 4 | partyid == 5 | partyid == 6 ~ 1, | |
| partyid <= 3 ~ 0)) %>% | |
| gss_reltrad6(reltrad) %>% | |
| select(porn, white, male, educ, income, attend, rep, age, reltrad) | |
| regg$reltrad <- relevel(factor(regg$reltrad), ref = "No Religion") | |
| out <- glm(porn ~ white + male + educ + income + attend + rep + age + reltrad, family = "binomial", data = regg) | |
| library(jtools) | |
| coef_names <- c("White" = "white", | |
| "Income" = "income", | |
| "Education" = "educ", | |
| "Age" = "age", | |
| "Male" = "male", | |
| "Republican" = "rep", | |
| "Church Attendance" = "attend", | |
| "Evangelical" = "reltradEvangelical", | |
| "Mainline" = "reltradMainline", | |
| "Black Prot." = "reltradBlack Prot.", | |
| "Other Faith" = "reltradOther Faith", | |
| "Catholic" = "reltradCatholic") | |
| gg <- plot_summs(out, scale = TRUE, robust = "HC3", coefs = coef_names, colors = "#5f2680") | |
| gg + | |
| theme_rb() + | |
| # add_text(x = -.5, y = 3.5, word = "Less Agreement", sz = 9) + | |
| add_text(x = .5, y = 11.5, word = "Favor a Ban", sz = 9) + | |
| labs(x = "", y = "", title = "Factors That Predict a Total Ban on Pornography", | |
| caption = "@ryanburge + @religiondata + @religiondata\nData: General Social Survey, 2021-2022") | |
| save("reg_porn_ban.png", ht = 5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment