Introduction
The thing that I want to do a study on the voters that voted for Bernie Sanders and Donald Trump and see who they have voted in the 2016 the most and see how they feel about ethnicity. The sub-population would be the Bernie Sanders Voters and Donald Trump Voters and I would be comparing on how they feel about ethnicities from 0-100 and see what other candidates were voted in the campaign of 2016.
Loading Data & Packages
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
library(gapminder)
library(ggplot2)
library(readr)
library(knitr)
Voter_Data_2019 <- read_csv("~/Downloads/Voter Data 2019.csv") %>%
select(Sanders_Trump_2016,pp_demprim16_2016,pp_repprim16_2016,ft_black_2016,ft_white_2016,ft_hisp_2016,ft_asian_2016,pp_demprim16_2016)
## Parsed with column specification:
## cols(
## .default = col_double(),
## weight_18_24_2018 = col_logical(),
## izip_2019 = col_character(),
## housevote_other_2019 = col_character(),
## senatevote_other_2019 = col_character(),
## senatevote2_other_2019 = col_character(),
## SenCand1Name_2019 = col_character(),
## SenCand1Party_2019 = col_character(),
## SenCand2Name_2019 = col_character(),
## SenCand2Party_2019 = col_character(),
## SenCand3Name_2019 = col_character(),
## SenCand3Party_2019 = col_character(),
## SenCand1Name2_2019 = col_character(),
## SenCand1Party2_2019 = col_character(),
## SenCand2Name2_2019 = col_character(),
## SenCand2Party2_2019 = col_character(),
## SenCand3Name2_2019 = col_character(),
## SenCand3Party2_2019 = col_character(),
## governorvote_other_2019 = col_character(),
## GovCand1Name_2019 = col_character(),
## GovCand1Party_2019 = col_character()
## # ... with 108 more columns
## )
## See spec(...) for full column specifications.
## Warning: 800 parsing failures.
## row col expected actual file
## 2033 weight_18_24_2018 1/0/T/F/TRUE/FALSE .917710168467982 '~/Downloads/Voter Data 2019.csv'
## 2828 weight_18_24_2018 1/0/T/F/TRUE/FALSE 1.41022291345592 '~/Downloads/Voter Data 2019.csv'
## 4511 weight_18_24_2018 1/0/T/F/TRUE/FALSE 1.77501243840922 '~/Downloads/Voter Data 2019.csv'
## 7264 weight_18_24_2018 1/0/T/F/TRUE/FALSE 1.29486870319614 '~/Downloads/Voter Data 2019.csv'
## 7277 weight_18_24_2018 1/0/T/F/TRUE/FALSE 1.44972719707603 '~/Downloads/Voter Data 2019.csv'
## .... ................. .................. ................ .................................
## See problems(...) for more details.
head(Voter_Data_2019)
## # A tibble: 6 x 7
## Sanders_Trump_2… pp_demprim16_20… pp_repprim16_20… ft_black_2016 ft_white_2016
## <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 1 1 NA 95 94
## 2 2 NA 1 97 99
## 3 1 1 NA 77 83
## 4 1 3 NA 99 51
## 5 2 NA 4 91 75
## 6 1 1 NA 100 97
## # … with 2 more variables: ft_hisp_2016 <dbl>, ft_asian_2016 <dbl>
Data Preparation
Voter_Data_2019 <- mutate(Voter_Data_2019,
Sanders_Trump_2016=ifelse(Sanders_Trump_2016==1,"Bernie Sanders Voters",
ifelse(Sanders_Trump_2016==2,"Donald Trump Voters",
ifelse(Sanders_Trump_2016==3,"Don't know",NA))))
head(Voter_Data_2019)
## # A tibble: 6 x 7
## Sanders_Trump_2… pp_demprim16_20… pp_repprim16_20… ft_black_2016 ft_white_2016
## <chr> <dbl> <dbl> <dbl> <dbl>
## 1 Bernie Sanders … 1 NA 95 94
## 2 Donald Trump Vo… NA 1 97 99
## 3 Bernie Sanders … 1 NA 77 83
## 4 Bernie Sanders … 3 NA 99 51
## 5 Donald Trump Vo… NA 4 91 75
## 6 Bernie Sanders … 1 NA 100 97
## # … with 2 more variables: ft_hisp_2016 <dbl>, ft_asian_2016 <dbl>
[If voted in the Democratic primary:] Who did you vote for in the primary?
Voter_Data_2019 <- mutate(Voter_Data_2019,
pp_demprim16_2016=ifelse(pp_demprim16_2016==1,"Hillary Clinton",
ifelse(pp_demprim16_2016==2,"Bernie Sanders",
ifelse(pp_demprim16_2016==3,"Someone else",
ifelse(pp_demprim16_2016==4,"Don't recall",NA)))))
head(Voter_Data_2019)
## # A tibble: 6 x 7
## Sanders_Trump_2… pp_demprim16_20… pp_repprim16_20… ft_black_2016 ft_white_2016
## <chr> <chr> <dbl> <dbl> <dbl>
## 1 Bernie Sanders … Hillary Clinton NA 95 94
## 2 Donald Trump Vo… <NA> 1 97 99
## 3 Bernie Sanders … Hillary Clinton NA 77 83
## 4 Bernie Sanders … Someone else NA 99 51
## 5 Donald Trump Vo… <NA> 4 91 75
## 6 Bernie Sanders … Hillary Clinton NA 100 97
## # … with 2 more variables: ft_hisp_2016 <dbl>, ft_asian_2016 <dbl>
Voter_Data_2019<- Voter_Data_2019%>%
mutate(pp_demprim16_2016 = factor(pp_demprim16_2016, levels = c("Bernie Sanders",
"Hillary Clinton"))) %>%
mutate(Sanders_Trump_2016 = factor(Sanders_Trump_2016, levels = c("Bernie Sanders Voters",
"Donald Trump Voters")))
Data Exploration
table(Voter_Data_2019$Sanders_Trump_2016,
Voter_Data_2019$pp_demprim16_2016)%>%
prop.table(1)%>%
round(2)
##
## Bernie Sanders Hillary Clinton
## Bernie Sanders Voters 0.43 0.57
## Donald Trump Voters 0.68 0.32
In this table, it shows how Bernie Sanders Voters seem to have voted for Hillary Clinton more than Bernie Sanders did, where Bernie Sanders was (0.43) and Hillary Clinton is (0.57). Those who are Donald Trump Voters, they have voted for Bernie Sanders more than Hillary Clinton, where Bernie Sanders was (0.68), and Hillary Clinton was (0.32).
[If voted in the Republican primary:] Who did you vote for in the primary?
Voter_Data_2019 <- mutate(Voter_Data_2019,
pp_repprim16_2016=ifelse(pp_repprim16_2016==1,"Donald Trump",
ifelse(pp_repprim16_2016==2,"John Kasich",
ifelse(pp_repprim16_2016==3,"Ted Cruz",
ifelse(pp_repprim16_2016==4,"Marco Rubio",
ifelse(pp_repprim16_2016==5,"Someone else",
ifelse(pp_repprim16_2016==6,"Don't recall",NA)))))))
head(Voter_Data_2019)
## # A tibble: 6 x 7
## Sanders_Trump_2… pp_demprim16_20… pp_repprim16_20… ft_black_2016 ft_white_2016
## <fct> <fct> <chr> <dbl> <dbl>
## 1 Bernie Sanders … Hillary Clinton <NA> 95 94
## 2 Donald Trump Vo… <NA> Donald Trump 97 99
## 3 Bernie Sanders … Hillary Clinton <NA> 77 83
## 4 Bernie Sanders … <NA> <NA> 99 51
## 5 Donald Trump Vo… <NA> Marco Rubio 91 75
## 6 Bernie Sanders … Hillary Clinton <NA> 100 97
## # … with 2 more variables: ft_hisp_2016 <dbl>, ft_asian_2016 <dbl>
Voter_Data_2019<- Voter_Data_2019%>%
mutate(pp_repprim16_2016 = factor(pp_repprim16_2016, levels = c("Donald Trump",
"John Kasich",
"Marco Rubio ",
"Ted Cruz"))) %>%
mutate(Sanders_Trump_2016 = factor(Sanders_Trump_2016, levels = c("Bernie Sanders Voters",
"Donald Trump Voters")))
table(Voter_Data_2019$pp_repprim16_2016,
Voter_Data_2019$Sanders_Trump_2016)%>%
prop.table(2)%>%
round(2)
##
## Bernie Sanders Voters Donald Trump Voters
## Donald Trump 0.27 0.60
## John Kasich 0.57 0.09
## Marco Rubio 0.00 0.00
## Ted Cruz 0.16 0.32
In this table, it shows how Bernie Sanders Voters seem to have voted for John Kasich for the most in the Republican Party which was 0.57. For Donald Trump Voters, it shows that the voters have voted for Donald Trump the most, which was 0.60.
If the 2016 election had been a race between [insert based on randomization order: the Democrat, Bernie Sanders, and the Republican, Donald Trump, / the Republican, Donald Trump, and the Democrat, Bernie Sanders,] who would you have preferred? [Order of Sanders and Trump randomized]
unique(Voter_Data_2019$Sanders_Trump_2016)
## [1] Bernie Sanders Voters Donald Trump Voters <NA>
## Levels: Bernie Sanders Voters Donald Trump Voters
Year 2016
Feelings towards black and white people between Bernie Sander Voters and Donald Trump Voters - (2016)
Voter_Data_2019<-Voter_Data_2019 %>%
mutate(ft_black_2016=ifelse(ft_black_2016>100,NA,ft_black_2016),
ft_white_2016=ifelse(ft_white_2016>100,NA,ft_white_2016))
unique(Voter_Data_2019$ft_black_2016)
## [1] 95 97 77 99 91 100 20 55 62 90 69 51 93 4 56 19 72 26
## [19] 82 81 25 67 74 59 64 87 52 50 0 NA 11 76 89 71 86 75
## [37] 94 63 80 60 79 70 49 58 57 61 48 98 78 88 41 66 45 36
## [55] 30 84 96 54 42 92 40 44 73 5 53 65 7 10 9 1 16 39
## [73] 27 29 85 28 46 83 31 22 24 68 38 35 43 6 21 23 13 2
## [91] 3 33 37 12 18 47 14 34 15 8 32 17
unique(Voter_Data_2019$ft_white_2016)
## [1] 94 99 83 51 75 97 60 100 52 85 49 59 90 50 76 78 92 95
## [19] 87 81 91 44 74 98 84 56 NA 55 22 79 86 70 62 53 61 63
## [37] 20 48 80 58 71 57 88 25 89 96 33 11 69 64 93 68 67 35
## [55] 72 45 66 46 65 27 82 40 41 73 77 54 31 30 5 34 10 37
## [73] 43 26 12 47 15 4 2 29 0 21 24 36 19 38 39 28 18 1
## [91] 9 14 32 7 3 42 16 6 23 17 8
Average Feelings (0-100) towards BLACK people - (2016)
Voter_Data_2019 %>%
filter(Sanders_Trump_2016 %in% c("Bernie Sanders Voters","Donald Trump Voters")) %>%
group_by(Sanders_Trump_2016)%>%
summarize(AVG = mean(ft_black_2016, na.rm=TRUE))
## # A tibble: 2 x 2
## Sanders_Trump_2016 AVG
## <fct> <dbl>
## 1 Bernie Sanders Voters 77.4
## 2 Donald Trump Voters 65.9
When Bernie Sanders Voter and Donald Trump Voters asked to rate Black people on a scale from 0 to 100, Bernie Sanders Voters gave an average rating of 77.43284, and Donald Trump Voters gave an average score of 65.86364. This indicates that Bernie Sanders Voters feel more favorably towards Black people than Donald Trump Voters do.
Histogram for BLACK people - (2016)
Voter_Data_2019%>%
filter(Sanders_Trump_2016 %in% c("Bernie Sanders Voters","Donald Trump Voters")) %>%
ggplot()+
geom_histogram(aes(x=ft_black_2016))+
facet_wrap(~Sanders_Trump_2016)
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 207 rows containing non-finite values (stat_bin).

Average Feelings (0-100) towards WHITE people - (2016)
Voter_Data_2019 %>%
filter(Sanders_Trump_2016 %in% c("Bernie Sanders Voters","Donald Trump Voters")) %>%
group_by(Sanders_Trump_2016)%>%
summarize(AVG = mean(ft_white_2016, na.rm=TRUE))
## # A tibble: 2 x 2
## Sanders_Trump_2016 AVG
## <fct> <dbl>
## 1 Bernie Sanders Voters 70.9
## 2 Donald Trump Voters 80.4
When Bernie Sanders Voter and Donald Trump Voters asked to rate White people on a scale from 0 to 100, Bernie Sanders Voters gave an average rating of 70.86319, and Donald Trump Voters gave an average score of 80.41230. This indicates that Donald Trump Voters feel more favorably towards White people than Bernie Sanders Voters do.
Histogram for WHITE people - (2016)
Voter_Data_2019%>%
filter(Sanders_Trump_2016 %in% c("Bernie Sanders Voters","Donald Trump Voters")) %>%
ggplot()+
geom_histogram(aes(x=ft_white_2016))+
facet_wrap(~Sanders_Trump_2016)
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 195 rows containing non-finite values (stat_bin).

Feelings towards Hispanic and Asian people between Bernie Sander Voters and Donald Trump Voters - (2016)
Voter_Data_2019<-Voter_Data_2019 %>%
mutate(ft_hisp_2016=ifelse(ft_hisp_2016>100,NA,ft_hisp_2016),
ft_asian_2016=ifelse(ft_asian_2016>100,NA,ft_asian_2016))
unique(Voter_Data_2019$ft_hisp_2016)
## [1] 90 100 77 98 95 6 80 82 66 53 61 50 97 40 47 51 76 99
## [19] 41 56 27 69 70 87 78 10 NA 18 59 85 91 55 21 88 52 57
## [37] 62 94 92 25 19 75 63 71 45 30 49 39 81 74 93 48 96 83
## [55] 67 84 58 60 26 5 20 65 79 38 9 73 72 89 36 68 54 86
## [73] 4 46 64 29 24 1 34 0 44 12 35 23 33 42 22 31 32 3
## [91] 16 13 28 2 11 37 15 8 14 43 17 7
unique(Voter_Data_2019$ft_asian_2016)
## [1] 90 100 99 93 98 31 53 80 61 50 96 81 79 68 92 87 91 83
## [19] 62 85 55 67 NA 10 51 71 75 70 86 82 60 78 8 88 94 89
## [37] 57 54 52 69 63 47 97 72 77 56 59 76 32 73 48 84 21 95
## [55] 30 65 66 49 41 40 74 17 33 28 29 42 2 4 36 64 0 1
## [73] 46 6 43 35 13 20 26 58 37 45 5 25 3 22 44 23 39 19
## [91] 14 7 12 9 38 27 11 16 34 18 24 15
Average Feelings (0-100) towards HISPANIC people - (2016)
Voter_Data_2019 %>%
filter(Sanders_Trump_2016 %in% c("Bernie Sanders Voters","Donald Trump Voters")) %>%
group_by(Sanders_Trump_2016)%>%
summarize(AVG = mean(ft_hisp_2016, na.rm=TRUE))
## # A tibble: 2 x 2
## Sanders_Trump_2016 AVG
## <fct> <dbl>
## 1 Bernie Sanders Voters 75.0
## 2 Donald Trump Voters 65.7
When Bernie Sanders Voter and Donald Trump Voters asked to rate Hispanic people on a scale from 0 to 100, Bernie Sanders Voters gave an average rating of 75.02662, and Donald Trump Voters gave an average score of 65.69464. This indicates that Bernie Sanders Voters feel more favorably towards Hispanic people than Donald Trump Voters do.
Histogram for HISPANIC people - (2016)
Voter_Data_2019%>%
filter(Sanders_Trump_2016 %in% c("Bernie Sanders Voters","Donald Trump Voters")) %>%
ggplot()+
geom_histogram(aes(x=ft_hisp_2016))+
facet_wrap(~Sanders_Trump_2016)
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 201 rows containing non-finite values (stat_bin).

Average Feelings (0-100) towards ASIAN people - (2016)
Voter_Data_2019 %>%
filter(Sanders_Trump_2016 %in% c("Bernie Sanders Voters","Donald Trump Voters")) %>%
group_by(Sanders_Trump_2016)%>%
summarize(AVG = mean(ft_asian_2016, na.rm=TRUE))
## # A tibble: 2 x 2
## Sanders_Trump_2016 AVG
## <fct> <dbl>
## 1 Bernie Sanders Voters 76.2
## 2 Donald Trump Voters 71.8
When Bernie Sanders Voter and Donald Trump Voters asked to rate Asian people on a scale from 0 to 100, Bernie Sanders Voters gave an average rating of 76.16075, and Donald Trump Voters gave an average score of 71.79782. This indicates that Bernie Sanders Voters feel more favorably towards Asian people than Donald Trump Voters do.
Histogram for ASIAN people - (2016)
Voter_Data_2019%>%
filter(Sanders_Trump_2016 %in% c("Bernie Sanders Voters","Donald Trump Voters")) %>%
ggplot()+
geom_histogram(aes(x=ft_asian_2016))+
facet_wrap(~Sanders_Trump_2016)
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 211 rows containing non-finite values (stat_bin).

Conclusions
From this topic, I am concluding the fact that the reason why Donald Trump has won the campaign in 2016 is because when Bernie Sanders lost to Hillary Clinton, some of Bernie Sanders voters didn’t participate in voting for Hillary Clinton, which gave the Democratics a disadvantage in the final part of the presidential race, resulting in Donald Trump winning the election. The differences that I also found out about my sub-population, which was Bernie Sander Voters and Donald Trump Voters, was the person they voted for the most in their political party. For Bernie Sander Voters, it seems that Hillary Clinton had the more votes than Bernie Sanders even though they were Bernie Sander Voters. For Donald Trump Voters, Donald Trump had the most votes than any of the Republican Party. Also, I have found out that, in terms of ethnicity, Donald Trump Voters have favored the White people more than other ethnicity and Bernie Sander Voters favored Blacks, Asian, and Hispanic people more than Donald Trump Voters.