#install.packages("readr")
#install.packages("dplyr")
library(readr)
## Warning: package 'readr' was built under R version 3.6.3
library(dplyr)
## Warning: package 'dplyr' was built under R version 3.6.3
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
voterdata<-read.csv("F:/Abbreviated Dataset Labeled.csv")
The two groups of respondents I chose from this data are Democrats and Republicans, which can be found in the variable PartyIdentification. I will compare them on different factors on the tables below.

Democrats’ vs Republicans’ Beliefs on How Immigration Should be

voterdata%>%
  filter(PartyIdentification %in% c("Democrat", "Republican"))%>%
  group_by(PartyIdentification, ImmigrationShouldBe)%>%
  summarize(n=n())%>%
  mutate(percent=n/sum(n))
## Warning: Factor `ImmigrationShouldBe` contains implicit NA, consider using
## `forcats::fct_explicit_na`
## # A tibble: 14 x 4
## # Groups:   PartyIdentification [2]
##    PartyIdentification ImmigrationShouldBe     n percent
##    <fct>               <fct>               <int>   <dbl>
##  1 Democrat            Much Easier           310 0.103  
##  2 Democrat            Much Harder           609 0.203  
##  3 Democrat            No change             671 0.223  
##  4 Democrat            Not Sure              270 0.0899 
##  5 Democrat            Slightly Easier       566 0.188  
##  6 Democrat            Slightly Harder       555 0.185  
##  7 Democrat            <NA>                   23 0.00766
##  8 Republican          Much Easier           153 0.0662 
##  9 Republican          Much Harder           652 0.282  
## 10 Republican          No change             593 0.257  
## 11 Republican          Not Sure              102 0.0441 
## 12 Republican          Slightly Easier       353 0.153  
## 13 Republican          Slightly Harder       442 0.191  
## 14 Republican          <NA>                   16 0.00692
Based on the table above, most democrats(approximately 22.3%) believe that there should be no change in which the country handles immigration.On the other hand, most Republicans (approximately 28%) think immigration should be much harder.

Democrats’ vs Republicans’ Beliefs on Death Penalty

voterdata%>%
  filter(PartyIdentification %in% c("Democrat", "Republican"))%>%
  group_by(PartyIdentification, DeathPenalty)%>%
  summarize(n=n())%>%
  mutate(percent=n/sum(n))
## Warning: Factor `DeathPenalty` contains implicit NA, consider using
## `forcats::fct_explicit_na`
## # A tibble: 8 x 4
## # Groups:   PartyIdentification [2]
##   PartyIdentification DeathPenalty     n percent
##   <fct>               <fct>        <int>   <dbl>
## 1 Democrat            Favor         1289 0.429  
## 2 Democrat            Not Sure       584 0.194  
## 3 Democrat            Oppose        1110 0.370  
## 4 Democrat            <NA>            21 0.00699
## 5 Republican          Favor         1835 0.794  
## 6 Republican          Not Sure       211 0.0913 
## 7 Republican          Oppose         248 0.107  
## 8 Republican          <NA>            17 0.00736
Based on the table above, the majority (79%) of the Repulicans favor death penalty. As for the Democrats, their beliefs on death penalty are divided since approximately 43% of Democrats favor death penalty and approximately 37% of them oppose it.

Democrats’ vs Republicans’ Views on the Frequency of Death Penalty

voterdata%>%
  filter(PartyIdentification %in% c("Democrat", "Republican"))%>%
  group_by(PartyIdentification, DeathPenaltyFreq)%>%
  summarize(n=n())%>%
  mutate(percent=n/sum(n))
## Warning: Factor `DeathPenaltyFreq` contains implicit NA, consider using
## `forcats::fct_explicit_na`
## # A tibble: 10 x 4
## # Groups:   PartyIdentification [2]
##    PartyIdentification DeathPenaltyFreq     n percent
##    <fct>               <fct>            <int>   <dbl>
##  1 Democrat            About Right        376 0.125  
##  2 Democrat            Not Often Enough   894 0.298  
##  3 Democrat            Not Sure           604 0.201  
##  4 Democrat            Too Often         1105 0.368  
##  5 Democrat            <NA>                25 0.00832
##  6 Republican          About Right        389 0.168  
##  7 Republican          Not Often Enough  1427 0.617  
##  8 Republican          Not Sure           314 0.136  
##  9 Republican          Too Often          172 0.0744 
## 10 Republican          <NA>                 9 0.00389
Based on the table above, most Democrats (37%) believe that death penalty is being used too frequetly whereas most Republicans (62%) believe that death penalty is not being used frequently enough.
The results from this table present a relationship with the results from the table above this one about the Democrats’ and Republicans’ views on death penalty because most Democrats oppose death penalties and feel that it has been used too frequently. On the other hand, most Republicans favor death penalty and believe that it has not being used frequently enough.

The Comparsion between Democrats’ vs Republicans’ Average Feeling Towards Christians (0-100)

voterdata%>%
  filter(PartyIdentification %in% c("Democrat", "Republican"))%>%
  group_by(PartyIdentification)%>%
  summarize(avgftchrist=mean(ft_christ_2017, na.rm=TRUE))
## # A tibble: 2 x 2
##   PartyIdentification avgftchrist
##   <fct>                     <dbl>
## 1 Democrat                   63.8
## 2 Republican                 85.4
Based on the table above, the average feeling towards Christians for Democrats is lower than that for Republicans (63.82 < 85.38).

Democrat’s vs Republicans’ on Gun Ownership

voterdata%>%
  filter(PartyIdentification %in% c("Democrat", "Republican"))%>%
  group_by(PartyIdentification, GunOwnership)%>%
  summarize(n=n())%>%
  mutate(percent=n/sum(n))
## Warning: Factor `GunOwnership` contains implicit NA, consider using
## `forcats::fct_explicit_na`
## # A tibble: 8 x 4
## # Groups:   PartyIdentification [2]
##   PartyIdentification GunOwnership            n percent
##   <fct>               <fct>               <int>   <dbl>
## 1 Democrat            Dont Know              82 0.0273 
## 2 Democrat            Gun in Household      892 0.297  
## 3 Democrat            No Gun in Household  2014 0.670  
## 4 Democrat            <NA>                   16 0.00533
## 5 Republican          Dont Know             235 0.102  
## 6 Republican          Gun in Household     1092 0.473  
## 7 Republican          No Gun in Household   934 0.404  
## 8 Republican          <NA>                   50 0.0216
Based on the table generated above, more Republicans carry guns in their households than Democrats (1092 Republicans > 892 Democrats). Also, the majority (67%) of Democrats do not have guns in their households.

Democrat’s vs Republicans’ Support on Higher Taxes on Wealthy People

voterdata%>%
  filter(PartyIdentification %in% c("Democrat", "Republican"))%>%
  group_by(PartyIdentification,TaxWealthy)%>%
  summarize(n=n())%>%
  mutate(percent=n/sum(n))
## Warning: Factor `TaxWealthy` contains implicit NA, consider using
## `forcats::fct_explicit_na`
## # A tibble: 8 x 4
## # Groups:   PartyIdentification [2]
##   PartyIdentification TaxWealthy     n percent
##   <fct>               <fct>      <int>   <dbl>
## 1 Democrat            Favor       2639 0.878  
## 2 Democrat            Not sure     208 0.0692 
## 3 Democrat            Oppose       147 0.0489 
## 4 Democrat            <NA>          10 0.00333
## 5 Republican          Favor        606 0.262  
## 6 Republican          Not sure     319 0.138  
## 7 Republican          Oppose      1381 0.598  
## 8 Republican          <NA>           5 0.00216
Based on the table above, the majority (88%) of Democrats believe that wealthy people should be taxed more. This percentage is much higher than the percentage of Republicans (26%) who believe the same way. Most republicans are against the idea that wealthy people should be taxed more as 60% of them said in the table.