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
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 3.6.3
voterdata<-read.csv("F:/Abbreviated Dataset Labeled.csv")
The two groups of respondents I chose from this data are male and female votes, which can be found in the variable “gender”. I will compare them on different factors on the tables below. The logical order for the categorical responses (“AffirmativeAction”, “EconomyBetterWorse” and “ReligiousImportance”) have been rearranged in this document. Furthermore, I have generated histograms for the continuous variables (“ft_police_2017” and “ft_dem_2017”).
Male vs Female Support on Affirmative Action
voterdata_updated <- voterdata%>%
mutate(AffirmativeAction = factor(AffirmativeAction, levels=c("Favor", "Oppose", "Not sure")))
prop.table(table(voterdata_updated$AffirmativeAction, voterdata_updated$gender),2)
##
## Female Male
## Favor 0.3385417 0.2492976
## Oppose 0.3559028 0.5905492
## Not sure 0.3055556 0.1601533
Based on the table generated above, the majority of the male respondents(59%) do not favor affirmative action. On the other hand, there is no significant difference among the ways the female respondents feel about affirmative action. (about 34% favor affirmative action, about 31% are not sure about it and about 36% said they oppose it)
The Comparison between Male vs Female’s Average Feelings Towards Police
voterdata%>%
group_by(gender)%>%
summarize(avgft_police=mean(ft_police_2017, na.rm=TRUE))
## # A tibble: 2 x 2
## gender avgft_police
## <fct> <dbl>
## 1 Female 75.9
## 2 Male 75.5
I calculated the average feeling towards police using the “group_by” and “summarize” commands. The average feeling towards police for male respondents is approximately 75.51 whereas the average feeling towards police for female respondents is approximately 75.92. This implies that female respondents have higher average feeling towards police than male respondents.
Analyzing “ft_police_2017” for Male and Female Respondents with Histograms
voterdata%>%
filter(gender %in% c("Female", "Male"))%>%
ggplot()+geom_histogram(aes(x=ft_police_2017))+
facet_wrap(~gender)
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 3101 rows containing non-finite values (stat_bin).

The histograms above show the frequecy distributions of the values of the respondents’ feeling towards police for both genders. The histograms look similar to each other but the female respondents have more respondents who gave high values for their feelings towards police. This implies why the average feeling towards police for the female respondents is slightly higher than that for the male respondents.
Male vs Female Views on the Economy
voterdata_updated <- voterdata%>%
mutate(EconomyBetterWorse=factor(EconomyBetterWorse, levels=c("Getting Better","About the Same", "Getting Worse", "Not Sure")))
prop.table(table(voterdata_updated$EconomyBetterWorse, voterdata_updated$gender),2)
##
## Female Male
## Getting Better 0.21687639 0.24555612
## About the Same 0.37897853 0.33697308
## Getting Worse 0.35849988 0.39690198
## Not Sure 0.04564520 0.02056882
Based on the table produced, the female and male respondents have different views on the nation’s economy. Most of the female respondents (about 38%) said that the economy is about the same whereas most of the male respondents (about 40%) think that the economy is getting worse.
The Comparison between Male and Female’s Average Feeling Towards Democrats
voterdata%>%
group_by(gender)%>%
summarize(avgft_democrats=mean(ft_dem_2017, na.rm=TRUE))
## # A tibble: 2 x 2
## gender avgft_democrats
## <fct> <dbl>
## 1 Female 55.9
## 2 Male 42.2
Based on the output, the average feeling towards democrats for female respondents is higher than the average feeling towards democrats for male respondents. (55.85777 > 42.20541)
Analyzing “ft_dem_2017” for Male and Female Respondents
voterdata%>%
filter(gender %in% c("Male", "Female"))%>%
ggplot()+geom_histogram(aes(x=ft_dem_2017))+
facet_wrap(~gender)
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 3250 rows containing non-finite values (stat_bin).

The histograms above show the frequecy distribution of the values of the respondents’ feeling towards democrats for both genders. Based on the histograms, most of the female respondents gave high values for their feelings towards democrats and most of the male respondents provided low values. This result explains the average feeling towards democrats for the female respondents is higher than the average feeling towards democrats for the male respondents. (55.85777 > 42.20541)
Male vs Female Views on Religion
voterdata_updated <- voterdata%>%
mutate(ReligiousImportance=factor(ReligiousImportance, levels=c("Very Important","Somewhat Important", "Not too Important", "Not at all Important")))
prop.table(table(voterdata_updated$ReligiousImportance, voterdata_updated$gender),2)
##
## Female Male
## Very Important 0.4464198 0.3627351
## Somewhat Important 0.2565432 0.2671581
## Not too Important 0.1328395 0.1583630
## Not at all Important 0.1641975 0.2117438
Based on the table generated by the “prop.table” command, the most of the respondents for each gender believe that religion is very important. About 45% of the female respondents and about 36% of the male respondents responded “Very important”.