#install.packages("readr")
library(readr)
library(knitr)
voterdata<-read_csv("/Users/meiminshan/Desktop/Abbreviated Dataset Labeled(October Only)(1).csv")
## Parsed with column specification:
## cols(
##   .default = col_character(),
##   NumChildren = col_double()
## )
## See spec(...) for full column specifications.
head(voterdata)
## # A tibble: 6 x 34
##   gender race  education familyincome children region urbancity Vote2012
##   <chr>  <chr> <chr>     <chr>        <chr>    <chr>  <chr>     <chr>   
## 1 Female White 4-year    Prefer not … No       West   Suburb    Barack …
## 2 Female White Some Col… $60K-$69,999 No       West   Rural Ar… Mitt Ro…
## 3 Male   White High Sch… $50K-$59,999 No       Midwe… City      Mitt Ro…
## 4 Male   White Some Col… $70K-$79,999 No       South  City      Barack …
## 5 Male   White 4-year    $40K-$49,999 No       South  Suburb    Mitt Ro…
## 6 Female White 2-year    $30K-$39,999 No       West   Suburb    Barack …
## # … with 26 more variables: Vote2016 <chr>, TrumpSanders <chr>,
## #   PartyRegistration <chr>, PartyIdentification <chr>,
## #   PartyIdentification2 <chr>, PartyIdentification3 <chr>,
## #   NewsPublicAffairs <chr>, DemPrimary <chr>, RepPrimary <chr>,
## #   ImmigrantContributions <chr>, ImmigrantNaturalization <chr>,
## #   ImmigrationShouldBe <chr>, Abortion <chr>, GayMarriage <chr>,
## #   DeathPenalty <chr>, DeathPenaltyFreq <chr>, TaxWealthy <chr>,
## #   Healthcare <chr>, GlobWarmExist <chr>, GlobWarmingSerious <chr>,
## #   AffirmativeAction <chr>, Religion <chr>, ReligiousImportance <chr>,
## #   ChurchAttendance <chr>, PrayerFrequency <chr>, NumChildren <dbl>

Crosstabs

Do male & female respondents differ in whether or not they think it should be easier or harder for foreigners to immigrate to the United States legally?

Yes, it appears that men think it should be easier for foreigners to immigrate to the United States legally more than women. Women think it should be harder for foreigners to immigrate to the United States legally more than men.

library(dplyr)
## 
## 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
new_voterdata<-voterdata%>%
  mutate(ImmigrationShouldBe = factor(ImmigrationShouldBe,levels=c("Much Easier", "Slightly Easier", "No change", "Slightly Harder", "Much Harder", "Not Sure")))
table(new_voterdata$ImmigrationShouldBe,new_voterdata$gender)%>%
  prop.table(2)%>%
  round(2)
##                  
##                   Female Male
##   Much Easier       0.08 0.11
##   Slightly Easier   0.16 0.20
##   No change         0.21 0.27
##   Slightly Harder   0.19 0.18
##   Much Harder       0.27 0.20
##   Not Sure          0.10 0.04

Do male & female respondents differ in their support for allowing gays and lesbians to marry legally?

Yes, it appears that women are supporting gays and lesbians to marry legally more than men. Men are more likely to disagree gays and lesbians to marry legally than women.

new_voterdata<-voterdata%>%
  mutate(GayMarriage = factor(GayMarriage, levels=c("Favor", "Oppose", "Not sure")))
table(new_voterdata$GayMarriage,new_voterdata$gender)%>%
  prop.table(2)%>%
  round(2)
##           
##            Female Male
##   Favor      0.50 0.40
##   Oppose     0.37 0.49
##   Not sure   0.14 0.10

Do different ethnic groups differ in having number of children?

Yes, it appears that Black, Hispanic, Mixed, Native American Mixed, Other and White are more likely to have 0 children. Asian and Middle Eastern are more likely to have no more than 3 children.

prop.table(table(voterdata$NumChildren, voterdata$race),2)
##     
##             Asian        Black     HIspanic Middle Eastern        Mixed
##   0  0.6410256410 0.7620481928 0.7333333333   0.4000000000 0.7515151515
##   1  0.1965811966 0.1189759036 0.1012345679   0.1000000000 0.1454545455
##   2  0.1367521368 0.0753012048 0.1135802469   0.3000000000 0.0787878788
##   3  0.0256410256 0.0331325301 0.0345679012   0.2000000000 0.0121212121
##   4  0.0000000000 0.0060240964 0.0098765432   0.0000000000 0.0000000000
##   5  0.0000000000 0.0015060241 0.0000000000   0.0000000000 0.0000000000
##   6  0.0000000000 0.0015060241 0.0049382716   0.0000000000 0.0060606061
##   7  0.0000000000 0.0000000000 0.0000000000   0.0000000000 0.0000000000
##   8  0.0000000000 0.0000000000 0.0000000000   0.0000000000 0.0000000000
##   9  0.0000000000 0.0000000000 0.0000000000   0.0000000000 0.0000000000
##   15 0.0000000000 0.0000000000 0.0000000000   0.0000000000 0.0060606061
##   16 0.0000000000 0.0015060241 0.0000000000   0.0000000000 0.0000000000
##   17 0.0000000000 0.0000000000 0.0024691358   0.0000000000 0.0000000000
##   20 0.0000000000 0.0000000000 0.0000000000   0.0000000000 0.0000000000
##     
##      Native American Mixed        Other        White
##   0           0.7118644068 0.7318840580 0.7870385042
##   1           0.1694915254 0.1304347826 0.1025194106
##   2           0.0508474576 0.0724637681 0.0763745841
##   3           0.0338983051 0.0362318841 0.0244018381
##   4           0.0000000000 0.0072463768 0.0064965932
##   5           0.0169491525 0.0144927536 0.0017429884
##   6           0.0000000000 0.0000000000 0.0011091745
##   7           0.0000000000 0.0000000000 0.0001584535
##   8           0.0169491525 0.0000000000 0.0000000000
##   9           0.0000000000 0.0000000000 0.0001584535
##   15          0.0000000000 0.0000000000 0.0000000000
##   16          0.0000000000 0.0000000000 0.0000000000
##   17          0.0000000000 0.0000000000 0.0000000000
##   20          0.0000000000 0.0072463768 0.0000000000

Do male and female responders differ in their support for raising taxes on families with incomes over $200,000 per year?

Yes, it appears that female responders are more likely to support raising taxes on families with incomes over $200, 000 per year. Male responders are more likely to oppose raising taxes on families with incomes over $200, 000 per year.

new_voterdata<-voterdata%>%
  mutate(TaxWealthy = factor(TaxWealthy, levels=c("Favor", "Oppose", "Not sure")))
table(new_voterdata$TaxWealthy, new_voterdata$gender)%>%
  prop.table(2)%>%
  round(2)
##           
##            Female Male
##   Favor      0.67 0.53
##   Oppose     0.20 0.40
##   Not sure   0.13 0.07

Conclusions