#Intro For this assignment I used a poll data set from fivethirtyeight, ‘Do You Know Where America Stands On Guns?’ focused on the opinions of Gun Control, which they asked about access, age, training ect that should be required from various survey results. Support is rated per question and the data also shows a breakdown of opinions between democrats and republicans. ## in terms of better understanding the questions, I added one here for easier reference age-21= What share of Americans support raising the minimum purchase age to 21?; more can be found on the article https://projects.fivethirtyeight.com/guns-parkland-polling-quiz/

library(ggplot2)
library(stringr)

#1. Do You Know Where America Stands On Guns? ###Data frame- reminder to click on raw data

Guns.poll <- read.csv(file ="https://raw.githubusercontent.com/fivethirtyeight/data/master/poll-quiz-guns/guns-polls.csv", header = TRUE,  stringsAsFactors = FALSE) 
head(Guns.poll)
##   Question   Start     End           Pollster        Population Support
## 1   age-21 2/20/18 2/23/18           CNN/SSRS Registered Voters      72
## 2   age-21 2/27/18 2/28/18          NPR/Ipsos            Adults      82
## 3   age-21  3/1/18  3/4/18          Rasmussen            Adults      67
## 4   age-21 2/22/18 2/26/18 Harris Interactive Registered Voters      84
## 5   age-21  3/3/18  3/5/18         Quinnipiac Registered Voters      78
## 6   age-21  3/4/18  3/6/18             YouGov Registered Voters      72
##   Republican.Support Democratic.Support
## 1                 61                 86
## 2                 72                 92
## 3                 59                 76
## 4                 77                 92
## 5                 63                 93
## 6                 65                 80
##                                                                                                                                               URL
## 1                                                                                http://cdn.cnn.com/cnn/2018/images/02/25/rel3a.-.trump,.guns.pdf
## 2                   https://www.ipsos.com/en-us/npripsos-poll-majority-americans-support-policies-aimed-keep-guns-out-hands-dangerous-individuals
## 3 http://www.rasmussenreports.com/public_content/lifestyle/general_lifestyle/march_2018/americans_favor_raising_age_to_buy_gun_not_enlist_or_vote
## 4                                                                http://thehill.com/opinion/civil-rights/375993-americans-support-no-gun-under-21
## 5                                                                                      https://poll.qu.edu/national/release-detail?ReleaseID=2525
## 6                                                     https://d25d2506sfb94s.cloudfront.net/cumulus_uploads/document/zq33h2ipcl/econTabReport.pdf
str(Guns.poll)
## 'data.frame':    57 obs. of  9 variables:
##  $ Question          : chr  "age-21" "age-21" "age-21" "age-21" ...
##  $ Start             : chr  "2/20/18" "2/27/18" "3/1/18" "2/22/18" ...
##  $ End               : chr  "2/23/18" "2/28/18" "3/4/18" "2/26/18" ...
##  $ Pollster          : chr  "CNN/SSRS" "NPR/Ipsos" "Rasmussen" "Harris Interactive" ...
##  $ Population        : chr  "Registered Voters" "Adults" "Adults" "Registered Voters" ...
##  $ Support           : int  72 82 67 84 78 72 76 41 44 43 ...
##  $ Republican.Support: int  61 72 59 77 63 65 72 69 68 71 ...
##  $ Democratic.Support: int  86 92 76 92 93 80 86 20 20 24 ...
##  $ URL               : chr  "http://cdn.cnn.com/cnn/2018/images/02/25/rel3a.-.trump,.guns.pdf" "https://www.ipsos.com/en-us/npripsos-poll-majority-americans-support-policies-aimed-keep-guns-out-hands-dangerous-individuals" "http://www.rasmussenreports.com/public_content/lifestyle/general_lifestyle/march_2018/americans_favor_raising_a"| __truncated__ "http://thehill.com/opinion/civil-rights/375993-americans-support-no-gun-under-21" ...

##New Data Frame

new.guns <- Guns.poll[, c("Question","Pollster","Population","Republican.Support","Democratic.Support")]

#I remove the general support column because I would like to compare the party’s opinions and the URL since ‘pollster’ has similar info.

##Rename Columns

names(new.guns)[names(new.guns) == 'Pollster'] <- 'source'
names(new.guns)[names(new.guns) == 'Population'] <- 'sample'

#I renamed population to sample - the categories are Adults and Registered voters (there is likely a better term of this grouping), and the term Pollster seemed confusing so I switched it to ‘source’

#Conclusions ##I would like to compare the responses based on parties. I think it would be interesting to find where some opinions generally align and attempt to modify those policies first, such as raising the minumum age to 21, which generally has a lot of support. I also wonder how the sample of ‘adults’ vary in opinons compared to ‘registered voters’ and how law makers can potentially leverage this information. I would be very interested in a more detailed breakdown of regarding the question ‘What share of Americans support arming teachers?’ specifically the respondants carreers, and I would love to see parents vs folks with no children and how their opinions on this question would vary. Also shoudlnt folks with children in schools have more weight in the decision?- Thanks for reading!

Guns.poll <- read.csv('https://raw.githubusercontent.com/marjete/607.Assignment-1/main/Gun%20Poll.csv')
head(Guns.poll)
##   ï..Question   Start     End           Pollster        Population Support
## 1      age-21 2/20/18 2/23/18           CNN/SSRS Registered Voters      72
## 2      age-21 2/27/18 2/28/18          NPR/Ipsos            Adults      82
## 3      age-21  3/1/18  3/4/18          Rasmussen            Adults      67
## 4      age-21 2/22/18 2/26/18 Harris Interactive Registered Voters      84
## 5      age-21  3/3/18  3/5/18         Quinnipiac Registered Voters      78
## 6      age-21  3/4/18  3/6/18             YouGov Registered Voters      72
##   Republican.Support Democratic.Support
## 1                 61                 86
## 2                 72                 92
## 3                 59                 76
## 4                 77                 92
## 5                 63                 93
## 6                 65                 80
##                                                                                                                                               URL
## 1                                                                                http://cdn.cnn.com/cnn/2018/images/02/25/rel3a.-.trump,.guns.pdf
## 2                   https://www.ipsos.com/en-us/npripsos-poll-majority-americans-support-policies-aimed-keep-guns-out-hands-dangerous-individuals
## 3 http://www.rasmussenreports.com/public_content/lifestyle/general_lifestyle/march_2018/americans_favor_raising_age_to_buy_gun_not_enlist_or_vote
## 4                                                                http://thehill.com/opinion/civil-rights/375993-americans-support-no-gun-under-21
## 5                                                                                      https://poll.qu.edu/national/release-detail?ReleaseID=2525
## 6                                                     https://d25d2506sfb94s.cloudfront.net/cumulus_uploads/document/zq33h2ipcl/econTabReport.pdf