#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
voterdata%>%
group_by(gender, ImmigrationShouldBe)%>%
summarize(n=n())%>%
mutate(percent=n/sum(n))
## # A tibble: 14 x 4
## # Groups: gender [2]
## gender ImmigrationShouldBe n percent
## <chr> <chr> <int> <dbl>
## 1 Female Much Easier 306 0.0754
## 2 Female Much Harder 1078 0.266
## 3 Female No change 856 0.211
## 4 Female Not Sure 385 0.0948
## 5 Female Slightly Easier 641 0.158
## 6 Female Slightly Harder 767 0.189
## 7 Female <NA> 27 0.00665
## 8 Male Much Easier 414 0.105
## 9 Male Much Harder 788 0.2
## 10 Male No change 1062 0.270
## 11 Male Not Sure 169 0.0429
## 12 Male Slightly Easier 792 0.201
## 13 Male Slightly Harder 689 0.175
## 14 Male <NA> 26 0.00660
library(ggplot2)
voterdata%>%
group_by(gender, ImmigrationShouldBe)%>%
summarize(n=n())%>%
mutate(percent=n/sum(n))%>%
ggplot()+
geom_col(aes(x=gender, y=percent, fill=ImmigrationShouldBe))
According to the bar graph, it reveals that men are more likely to believe it should be easier for foreigners to immigrate to the United States legally than women. Women are more likely to believe it should be harder for foreigners to immigrate to the United States legally than men.
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.
library(dplyr)
voterdata%>%
group_by(gender, GayMarriage)%>%
summarize(n=n())%>%
mutate(percent=n/sum(n))
## # A tibble: 8 x 4
## # Groups: gender [2]
## gender GayMarriage n percent
## <chr> <chr> <int> <dbl>
## 1 Female Favor 2014 0.496
## 2 Female Not sure 548 0.135
## 3 Female Oppose 1487 0.366
## 4 Female <NA> 11 0.00271
## 5 Male Favor 1579 0.401
## 6 Male Not sure 406 0.103
## 7 Male Oppose 1937 0.492
## 8 Male <NA> 18 0.00457
library(ggplot2)
voterdata%>%
group_by(GayMarriage,gender)%>%
summarize(n=n())%>%
mutate(percent=n/sum(n))%>%
ggplot()+
geom_col(aes(x=gender, y=percent, fill=GayMarriage))
According to the bar graph, women mostly show support for gays and lesbians to marry legally. Men mostly oppose gays and lesbians to marry legally.
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.
library(dplyr)
voterdata%>%
group_by(race, NumChildren)%>%
summarize(n=n())%>%
mutate((percent=n/sum(n)))
## # A tibble: 63 x 4
## # Groups: race [9]
## race NumChildren n `(percent = n/sum(n))`
## <chr> <dbl> <int> <dbl>
## 1 Asian 0 75 0.625
## 2 Asian 1 23 0.192
## 3 Asian 2 16 0.133
## 4 Asian 3 3 0.025
## 5 Asian NA 3 0.025
## 6 Black 0 506 0.752
## 7 Black 1 79 0.117
## 8 Black 2 50 0.0743
## 9 Black 3 22 0.0327
## 10 Black 4 4 0.00594
## # … with 53 more rows
library(ggplot2)
voterdata%>%
group_by(race, NumChildren)%>%
summarize(n=n())%>%
mutate(percent=n/sum(n))%>%
ggplot()+
geom_col(aes(x=race, y=percent, fill=NumChildren))
According to the bar graph, it reveals that Asian mostly has 1 or 2 children or 0 children.
Black mostly has 0 children and could have more 3 children.
Hispanic mostly has 0 children and could have more 3 children.
Middle Eastern mostly has 2 or 3 children, but no more than 3 children.
Mixed mostly has 0 children and could have more 3 children.
Native American Mixed mostly has 1 children or 0 children and could have more than 3 children.
Other mostly has 0 children and could have more than 3 children.
White mostly has 0 children and could have more than 3 children.
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.
library(dplyr)
voterdata%>%
group_by(gender, TaxWealthy)%>%
summarize(n=n())%>%
mutate(percent=n/sum(n))
## # A tibble: 8 x 4
## # Groups: gender [2]
## gender TaxWealthy n percent
## <chr> <chr> <int> <dbl>
## 1 Female Favor 2706 0.667
## 2 Female Not sure 513 0.126
## 3 Female Oppose 827 0.204
## 4 Female <NA> 14 0.00345
## 5 Male Favor 2068 0.525
## 6 Male Not sure 293 0.0744
## 7 Male Oppose 1568 0.398
## 8 Male <NA> 11 0.00279
library(ggplot2)
voterdata%>%
group_by(TaxWealthy, gender)%>%
summarize(n=n())%>%
mutate(percent=n/sum(n))%>%
ggplot()+
geom_col(aes(x=gender, y=percent, fill=TaxWealthy))
According to the bar graph, women mostly show support for raising taxes on families with incomes over $200, 000 per year. Men mostly oppose raising taxes on families with incomes over $200, 000 per year.
Conclusions
Male respondents are more likely than female respondents to believe it should be easier for foreigners to immigrate to the United States legally.
Female respondents are more likely than male respondents to support gays and lesbians to marry legally.
Black, Hispanic, Mixed, Native American Mixed, Other, and White are more likely than Asian and Middle Eastern to have either 0 children or more than 3 children.
Female respondents are more likely than male respondents to support raising taxes on families with incomes over $200,000 per year.