Homosexuality polls

Plotting of polling data from Gallup about the acceptance homosexuality.

Jonatan Pallesen
05-24-2019

The data is from Gallup opinion polls of the US population. I was surprised about the degree of negative sentiments about homosexuality. It is steadily improving, but still 31% are against same-sex marriage, 30% think that homosexuality is immoral and 23% think that same-sex relationships should be illegal. I think that the most egregious of these are the two latter. There is a difference between having an opinion about religion and the institution of marriage, and wanting the state to force homosexual people not to be together.


read data


library(pacman)

p_load(tidyverse, magrittr, janitor)

source('../../src/extra.R', echo = F, encoding="utf-8")

read1 <- function(path){
  read_tsv(path) %>% clean_names() %>% 
    separate(date, into = c("year", "month", "day"), sep=" ") %>% 
    mutate(year = as.numeric(year)) %>% 
    filter(!(month %in% c("Nov", "Dec")))  
}

marriage_str <- "Same-sex marriage should not be valid\n" 

homosexuality_str <- "Homosexuality is morally wrong\n"

legal_str <- "Same-sex relationship should not be legal"

marriage <- read1("data/marriages.tsv") %>% 
  rename(!!sym(marriage_str) := should_not_be_valid)

legal <- read1("data/legal.tsv") %>% 
  group_by(year) %>% 
  summarise(!!sym(legal_str) := mean(should_not_be_legal))

moral <- read1("data/morally_acceptable.tsv") %>% 
  rename(!!sym(homosexuality_str) := morally_wrong)

df <- full_join(marriage, legal, by = "year") %>% full_join(moral, by="year")

plot


cats <- c(marriage_str, homosexuality_str, legal_str)

df %>% filter(year >= 2001) %>% 
  pivot_longer(cats, values_to="percent", names_to="position") %>% 
  mutate(position = factor(position, levels = cats)) %>% 
  ggplot(aes(x = year, y = percent, group = position, color = position)) +
  geom_line(size=1.2) +
  scale_x_continuous(breaks = seq(1998, 2018, 2)) +
  scale_y_continuous(
    limits = c(0, 70),
    sec.axis = sec_axis(~ ., breaks = c(23, 30.5), labels = c("23%", "30 / 31%")),
    labels = function(x) paste0(x, "%")
    ) +
  theme(legend.text=element_text(size=13),
        legend.position = "top",
        legend.title = element_blank()) +
  guides(color = guide_legend(
    ncol = 1,
    label.position = "bottom",
    keyheight = 2,
    label.vjust = 4)
    ) +
  labs(x = "", y = "")