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 male and female votes, which can be found in the variable “gender”. I will compare them on different factors on the tables below.
Male vs Female Support on Affirmative Action
prop.table(table(voterdata$gender, voterdata$AffirmativeAction),1)
##
## Favor Not sure Oppose
## Female 0.3385417 0.3055556 0.3559028
## Male 0.2492976 0.1601533 0.5905492
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
newdata1 <- voterdata%>%
filter(gender=="Male")
table(newdata1$ft_police_2017)
##
## 0 1 2 3 4 5 6 7 8 9 10 11 12 13 15 16 17 19 20 21
## 9 6 8 7 3 5 4 3 3 7 6 6 3 3 5 3 3 4 10 8
## 22 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
## 6 9 19 10 8 7 6 17 16 4 2 2 8 3 4 6 3 21 27 4
## 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
## 2 4 14 9 11 5 12 94 47 11 12 6 14 8 6 5 14 41 19 10
## 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
## 14 2 16 12 6 6 18 47 16 21 11 15 56 24 16 31 44 106 62 25
## 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
## 13 21 34 13 13 31 40 128 73 29 28 43 78 63 54 59 108 331
avgftpoilce_male=mean(newdata1$ft_police_2017, na.rm = TRUE)
newdata2 <- voterdata%>%
filter(gender=="Female")
table(newdata2$ft_police_2017)
##
## 0 1 2 3 4 5 6 7 9 10 11 12 13 14 16 17 18 19 20 21
## 16 6 4 5 3 10 4 2 3 12 5 2 2 5 3 4 2 4 7 3
## 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
## 5 2 2 14 7 4 8 6 19 13 7 4 5 5 4 6 7 6 15 13
## 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
## 11 4 7 15 16 9 10 14 80 42 26 21 8 15 16 4 11 22 35 23
## 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
## 9 12 14 22 23 13 18 30 50 27 26 14 23 71 24 34 37 49 101 57
## 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
## 19 13 32 39 21 18 40 51 102 77 28 23 41 67 62 78 75 140 337
avgftpolice_female=mean(newdata2$ft_police_2017, na.rm = TRUE)
avgftpoilce_male
## [1] 75.51218
avgftpolice_female
## [1] 75.91523
In order to calculate the average feeling towards police for each gender, I first created a dataset for the variable “ft_police_2017” for each gender using the filter and table commands. The first two tables represent the values of the feelings towards police for both genders. (The first one is for male respondents and the second table shows the table of values of the feeling towards police is for female respondents) I then calculated the average feeling towards police for each gender using the “mean” command. 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.
Male vs Female Views on the Economy
prop.table(table(voterdata$gender, voterdata$EconomyBetterWorse),1)
##
## About the Same Getting Better Getting Worse Not Sure
## Female 0.37897853 0.21687639 0.35849988 0.04564520
## Male 0.33697308 0.24555612 0.39690198 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
table(newdata1$ft_dem_2017)
##
## 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
## 129 126 75 71 31 55 55 21 16 28 70 47 22 18 7 13 15 7 2 8
## 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
## 33 31 16 10 11 39 14 17 16 12 36 30 11 9 4 11 4 4 15 3
## 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
## 21 21 3 8 8 10 10 5 9 12 64 30 15 9 9 15 15 9 11 11
## 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
## 36 14 7 9 12 15 12 4 7 16 30 21 12 4 13 52 17 16 21 19
## 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
## 52 34 6 6 12 26 14 6 10 19 56 31 13 9 12 14 15 9 16 27
## 100
## 93
avgftdem_male = mean(newdata1$ft_dem_2017, na.rm = TRUE)
table(newdata2$ft_dem_2017)
##
## 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
## 89 61 51 47 24 30 34 15 11 25 32 26 17 17 8 4 16 6 7 9
## 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
## 16 20 14 4 8 29 15 11 13 16 25 35 8 5 3 9 13 2 6 10
## 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
## 23 33 7 10 8 11 12 16 14 27 105 55 21 20 10 20 5 2 10 21
## 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
## 26 20 8 20 5 12 16 7 11 27 43 15 28 16 25 63 32 22 37 26
## 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
## 72 51 17 12 20 17 12 16 23 28 77 41 15 16 19 40 31 31 39 55
## 100
## 184
avgftdem_female = mean(newdata2$ft_dem_2017, na.rm = TRUE)
avgftdem_male
## [1] 42.20541
avgftdem_female
## [1] 55.85777
Using the same datasets from when I calculated the average feeling towards police, I computed the average feeling towards democrats for each gender. (The first table represents the values for the feeling towards democrats for male respondents and the second table is for the values of the feeling for female respondents) 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)
Male vs Female Views on Religion
prop.table(table(voterdata$gender, voterdata$ReligiousImportance),1)
##
## Not at all Important Not too Important Somewhat Important
## Female 0.1641975 0.1328395 0.2565432
## Male 0.2117438 0.1583630 0.2671581
##
## Very Important
## Female 0.4464198
## Male 0.3627351
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”.