Overview

This is the the data behind the quiz “Do You Know Where America Stands On Guns?”

Introduction

What share of Americans support stricter gun laws? When it comes to the specific policy debates, where does the American public stand? This is normally where the quiz answer that question for you?

Load library

library(tidyverse)
## -- Attaching packages --------------------------------------- tidyverse 1.3.0 --
## v ggplot2 3.3.3     v purrr   0.3.4
## v tibble  3.0.6     v dplyr   1.0.3
## v tidyr   1.1.2     v stringr 1.4.0
## v readr   1.4.0     v forcats 0.5.1
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()

Poll Quiz - Guns

guns-polls.csv contains the list of polls about guns that we used in our quiz. All polls have been taken after February 14, 2018, the date of the school shooting in Parkland, Florida.

Load data

aURL <- "https://raw.githubusercontent.com/fivethirtyeight/data/master/poll-quiz-guns/guns-polls.csv"

df <- read.csv(aURL)

Set subset of the columns in dataset. We don’t need “URL” column. We heed convert string to date and delete string columns

df["StartDate"] = as.Date(df$Start,"%m/%d/%y")
df["EndDate"] = as.Date(df$Start,"%m/%d/%y")
df = select(df, -URL, -Start, -End)

Convert dataframe to tidyverse

tdf = as_tibble(df)
str(tdf)
## tibble [57 x 8] (S3: tbl_df/tbl/data.frame)
##  $ Question          : chr [1:57] "age-21" "age-21" "age-21" "age-21" ...
##  $ Pollster          : chr [1:57] "CNN/SSRS" "NPR/Ipsos" "Rasmussen" "Harris Interactive" ...
##  $ Population        : chr [1:57] "Registered Voters" "Adults" "Adults" "Registered Voters" ...
##  $ Support           : int [1:57] 72 82 67 84 78 72 76 41 44 43 ...
##  $ Republican.Support: int [1:57] 61 72 59 77 63 65 72 69 68 71 ...
##  $ Democratic.Support: int [1:57] 86 92 76 92 93 80 86 20 20 24 ...
##  $ StartDate         : Date[1:57], format: "2018-02-20" "2018-02-27" ...
##  $ EndDate           : Date[1:57], format: "2018-02-20" "2018-02-27" ...

Statistical transformations

ggplot(data = tdf) + geom_bar(mapping = aes(x = Pollster)) +
  coord_flip()

Gun Laws

boxplot(select(tdf, Support, Republican.Support, Democratic.Support), main = 'Support stricter gun laws')

Conclusion

More democrats support stricter gun laws.