library(ggplot2)
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(readr)
Vote <- read_csv("~/Downloads/Voter.csv")
## 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.csv'
## 2828 weight_18_24_2018 1/0/T/F/TRUE/FALSE 1.41022291345592 '~/Downloads/Voter.csv'
## 4511 weight_18_24_2018 1/0/T/F/TRUE/FALSE 1.77501243840922 '~/Downloads/Voter.csv'
## 7264 weight_18_24_2018 1/0/T/F/TRUE/FALSE 1.29486870319614 '~/Downloads/Voter.csv'
## 7277 weight_18_24_2018 1/0/T/F/TRUE/FALSE 1.44972719707603 '~/Downloads/Voter.csv'
## .... ................. .................. ................ .......................
## See problems(...) for more details.
head(Vote)
## # A tibble: 6 x 1,282
## weight_2016 weight_2017 weight_panel_20… weight_latino_2… weight_18_24_20…
## <dbl> <dbl> <dbl> <dbl> <lgl>
## 1 0.358 0.438 0.503 NA NA
## 2 0.563 0.366 0.389 NA NA
## 3 0.552 0.550 0.684 NA NA
## 4 0.208 NA NA NA NA
## 5 0.334 0.346 0.322 NA NA
## 6 0.207 0.148 0.594 NA NA
## # … with 1,277 more variables: weight_overall_2018 <dbl>, weight_2019 <dbl>,
## # weight1_2018 <dbl>, weight1_2019 <dbl>, weight2_2019 <dbl>,
## # weight3_2019 <dbl>, cassfullcd <dbl>, vote2020_2019 <dbl>,
## # trumpapp_2019 <dbl>, fav_trump_2019 <dbl>, fav_obama_2019 <dbl>,
## # fav_hrc_2019 <dbl>, fav_sanders_2019 <dbl>, fav_putin_2019 <dbl>,
## # fav_schumer_2019 <dbl>, fav_pelosi_2019 <dbl>, fav_comey_2019 <dbl>,
## # fav_mueller_2019 <dbl>, fav_mcconnell_2019 <dbl>, fav_kavanaugh_2019 <dbl>,
## # fav_biden_2019 <dbl>, fav_warren_2019 <dbl>, fav_harris_2019 <dbl>,
## # fav_gillibrand_2019 <dbl>, fav_patrick_2019 <dbl>, fav_booker_2019 <dbl>,
## # fav_garcetti_2019 <dbl>, fav_klobuchar_2019 <dbl>, fav_gorsuch_2019 <dbl>,
## # fav_kasich_2019 <dbl>, fav_haley_2019 <dbl>, fav_bloomberg_2019 <dbl>,
## # fav_holder_2019 <dbl>, fav_avenatti_2019 <dbl>, fav_castro_2019 <dbl>,
## # fav_landrieu_2019 <dbl>, fav_orourke_2019 <dbl>,
## # fav_hickenlooper_2019 <dbl>, fav_pence_2019 <dbl>, add_confirm_2019 <dbl>,
## # izip_2019 <chr>, votereg_2019 <dbl>, votereg_f_2019 <dbl>,
## # regzip_2019 <dbl>, region_2019 <dbl>, turnout18post_2019 <dbl>,
## # tsmart_G2018_2019 <dbl>, tsmart_G2018_vote_type_2019 <dbl>,
## # tsmart_P2018_2019 <dbl>, tsmart_P2018_party_2019 <dbl>,
## # tsmart_P2018_vote_type_2019 <dbl>, housevote_2019 <dbl>,
## # housevote_other_2019 <chr>, senatevote_2019 <dbl>,
## # senatevote_other_2019 <chr>, senatevote2_2019 <dbl>,
## # senatevote2_other_2019 <chr>, SenCand1Name_2019 <chr>,
## # SenCand1Party_2019 <chr>, SenCand2Name_2019 <chr>,
## # SenCand2Party_2019 <chr>, SenCand3Name_2019 <chr>,
## # SenCand3Party_2019 <chr>, SenCand1Name2_2019 <chr>,
## # SenCand1Party2_2019 <chr>, SenCand2Name2_2019 <chr>,
## # SenCand2Party2_2019 <chr>, SenCand3Name2_2019 <chr>,
## # SenCand3Party2_2019 <chr>, governorvote_2019 <dbl>,
## # governorvote_other_2019 <chr>, GovCand1Name_2019 <chr>,
## # GovCand1Party_2019 <chr>, GovCand2Name_2019 <chr>,
## # GovCand2Party_2019 <chr>, GovCand3Name_2019 <chr>,
## # GovCand3Party_2019 <chr>, inst_court_2019 <dbl>, inst_media_2019 <dbl>,
## # inst_congress_2019 <dbl>, inst_justice_2019 <dbl>, inst_FBI_2019 <dbl>,
## # inst_military_2019 <dbl>, inst_church_2019 <dbl>, inst_business_2019 <dbl>,
## # Democrats_2019 <dbl>, Republicans_2019 <dbl>, Men_2019 <dbl>,
## # Women_2019 <dbl>, wm_2019 <dbl>, ww_2019 <dbl>, bm_2019 <dbl>,
## # bw_2019 <dbl>, hm_2019 <dbl>, hw_2019 <dbl>, rwm_2019 <dbl>,
## # rww_2019 <dbl>, rbm_2019 <dbl>, rbw_2019 <dbl>, pwm_2019 <dbl>, …
Renaming GovCand1Name_2019:
Vote <- Vote %>%
rename(GovCand1Name_2019, dem_governor_vote_2019 = GovCand1Name_2019)
Cleaning for Republicans_2019:
Vote <- Vote %>%
mutate(Republicans_2019 = ifelse(Republicans_2019>100, NA,Republicans_2019))
Vote %>%
select(dem_governor_vote_2019, Republicans_2019) %>%
filter(dem_governor_vote_2019 == "Andrew M. Cuomo"| dem_governor_vote_2019 == "David Garcia") %>%
group_by(dem_governor_vote_2019) %>%
summarize(AVERAGE = mean(Republicans_2019, na.rm = NA))
## # A tibble: 2 x 2
## dem_governor_vote_2019 AVERAGE
## <chr> <dbl>
## 1 Andrew M. Cuomo 33.4
## 2 David Garcia 41.6
This shows that voters of Cuomo and Garcia have strong opinions against Republicans due to their average rate being so low.
Vote %>%
filter(dem_governor_vote_2019 %in% c("Andrew M. Cuomo", "David Garcia")) %>%
ggplot()+
geom_histogram(aes(x=Republicans_2019))+
facet_wrap(~dem_governor_vote_2019)
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 99 rows containing non-finite values (stat_bin).
The plot represents how voters of Cuomo and Garcia are mostly against Republicans since they lean more on the lower averages as shown on the graph.
Vote %>%
select(dem_governor_vote_2019, healthreformbill_2019) %>%
filter(dem_governor_vote_2019 == "Andrew M. Cuomo"| dem_governor_vote_2019== "David Garcia") %>%
group_by(dem_governor_vote_2019, healthreformbill_2019) %>%
summarize(n=n()) %>%
mutate(percent=n/sum(n), healthreformbill_2019 = ifelse(healthreformbill_2019>10, NA,healthreformbill_2019))
## # A tibble: 12 x 4
## # Groups: dem_governor_vote_2019 [2]
## dem_governor_vote_2019 healthreformbill_2019 n percent
## <chr> <dbl> <int> <dbl>
## 1 Andrew M. Cuomo 1 188 0.493
## 2 Andrew M. Cuomo 2 36 0.0945
## 3 Andrew M. Cuomo 3 101 0.265
## 4 Andrew M. Cuomo 8 36 0.0945
## 5 Andrew M. Cuomo NA 1 0.00262
## 6 Andrew M. Cuomo NA 19 0.0499
## 7 David Garcia 1 74 0.372
## 8 David Garcia 2 8 0.0402
## 9 David Garcia 3 94 0.472
## 10 David Garcia 8 18 0.0905
## 11 David Garcia NA 2 0.0101
## 12 David Garcia NA 3 0.0151
Those who voted for Cuomo and Garcia mainly leaned more on having the Health Reform Bill expanded and repealed. Cuomo voters were at 49% and Garcia voters were at 37% for expanded. Meanwhile, Cuomo voters were at 27% and Garcia voters were at 47% for repealed.
new_Vote <- Vote %>%
filter(dem_governor_vote_2019 == "Andrew M. Cuomo"| dem_governor_vote_2019 == "David Garcia") %>%
mutate(favorhealth_2019 = ifelse(favorhealth_2019>10, NA,favorhealth_2019))
table(new_Vote$dem_governor_vote_2019, new_Vote$favorhealth_2019) %>%
prop.table(1)
##
## 1 2 3 4 8
## Andrew M. Cuomo 0.35911602 0.21823204 0.13259669 0.21270718 0.07734807
## David Garcia 0.30051813 0.13471503 0.12435233 0.36269430 0.07772021
The higher percentages for this question were for strongly favor with Cuomo voters at 36% and Garcia voters at 30%.
Variables renamed:
Vote <- Vote %>%
rename(imiss_i_2019, fam_med_leave2019 = imiss_i_2019)
Vote %>%
select(dem_governor_vote_2019, fam_med_leave2019) %>%
filter(dem_governor_vote_2019 == "Andrew M. Cuomo"| dem_governor_vote_2019 == "David Garcia") %>%
group_by(dem_governor_vote_2019, fam_med_leave2019) %>%
summarize(n=n()) %>%
mutate(percent=n/sum(n))
## # A tibble: 12 x 4
## # Groups: dem_governor_vote_2019 [2]
## dem_governor_vote_2019 fam_med_leave2019 n percent
## <chr> <dbl> <int> <dbl>
## 1 Andrew M. Cuomo 1 150 0.394
## 2 Andrew M. Cuomo 2 129 0.339
## 3 Andrew M. Cuomo 3 66 0.173
## 4 Andrew M. Cuomo 4 13 0.0341
## 5 Andrew M. Cuomo 8 4 0.0105
## 6 Andrew M. Cuomo NA 19 0.0499
## 7 David Garcia 1 57 0.286
## 8 David Garcia 2 76 0.382
## 9 David Garcia 3 44 0.221
## 10 David Garcia 4 15 0.0754
## 11 David Garcia 8 4 0.0201
## 12 David Garcia NA 3 0.0151
Cuomo voters and Garcia voters mainly lean on very important (Cuomo voters = 39%, Garcia voters= 29%) and somewhat important (Cuomo voters = 34%, Garcia voters = 38%).
Vote %>%
select(dem_governor_vote_2019, healthcarelaw1_2019) %>%
filter(dem_governor_vote_2019 == "Andrew M. Cuomo"| dem_governor_vote_2019 == "David Garcia") %>%
group_by(dem_governor_vote_2019, healthcarelaw1_2019) %>%
summarize(n=n()) %>%
mutate(percent=n/sum(n))
## # A tibble: 14 x 4
## # Groups: dem_governor_vote_2019 [2]
## dem_governor_vote_2019 healthcarelaw1_2019 n percent
## <chr> <dbl> <int> <dbl>
## 1 Andrew M. Cuomo 1 257 0.675
## 2 Andrew M. Cuomo 2 58 0.152
## 3 Andrew M. Cuomo 3 17 0.0446
## 4 Andrew M. Cuomo 4 11 0.0289
## 5 Andrew M. Cuomo 8 17 0.0446
## 6 Andrew M. Cuomo 98 2 0.00525
## 7 Andrew M. Cuomo NA 19 0.0499
## 8 David Garcia 1 126 0.633
## 9 David Garcia 2 33 0.166
## 10 David Garcia 3 15 0.0754
## 11 David Garcia 4 13 0.0653
## 12 David Garcia 8 8 0.0402
## 13 David Garcia 98 1 0.00503
## 14 David Garcia NA 3 0.0151
Cleaning for Democrats_2019:
Vote <- Vote %>%
mutate(Democrats_2019 = ifelse(Democrats_2019>100, NA,Democrats_2019))
Renaming GovCand2Name_2019:
Vote <- Vote %>%
rename(GovCand2Name_2019, rep_governor_vote_2019 = GovCand2Name_2019)
Vote %>%
select(rep_governor_vote_2019, Democrats_2019) %>%
filter(rep_governor_vote_2019 == "John H. Cox"| rep_governor_vote_2019 == "Doug Ducey") %>%
group_by(rep_governor_vote_2019) %>%
summarize(AVERAGE = mean(Democrats_2019, na.rm = NA))
## # A tibble: 2 x 2
## rep_governor_vote_2019 AVERAGE
## <chr> <dbl>
## 1 Doug Ducey 40.1
## 2 John H. Cox 51.4
The averages depict how Ducey and Cox voters lean more on against Democrats; however, Cox is in between at 51% as their average rate over 100.
Vote %>%
filter(rep_governor_vote_2019 %in% c("John H. Cox", "Doug Ducey")) %>%
ggplot()+
geom_histogram(aes(x=Democrats_2019))+
facet_wrap(~rep_governor_vote_2019)
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 144 rows containing non-finite values (stat_bin).
The charts shows how Ducey voters have weaker opinions on Democrats. Meanwhile, Cox voters have strong opinions that are mixedly dispersed around the chart. Both voters have higher averages leaning closer to 0.
Vote %>%
select(rep_governor_vote_2019, healthreformbill_2019) %>%
filter(rep_governor_vote_2019 == "John H. Cox"| rep_governor_vote_2019 == "Doug Ducey") %>%
group_by(rep_governor_vote_2019, healthreformbill_2019) %>%
summarize(n=n()) %>%
mutate(percent=n/sum(n))
## # A tibble: 12 x 4
## # Groups: rep_governor_vote_2019 [2]
## rep_governor_vote_2019 healthreformbill_2019 n percent
## <chr> <dbl> <int> <dbl>
## 1 Doug Ducey 1 74 0.372
## 2 Doug Ducey 2 8 0.0402
## 3 Doug Ducey 3 94 0.472
## 4 Doug Ducey 8 18 0.0905
## 5 Doug Ducey 98 2 0.0101
## 6 Doug Ducey NA 3 0.0151
## 7 John H. Cox 1 346 0.477
## 8 John H. Cox 2 56 0.0771
## 9 John H. Cox 3 222 0.306
## 10 John H. Cox 8 77 0.106
## 11 John H. Cox 98 1 0.00138
## 12 John H. Cox NA 24 0.0331
Voters of Ducey and Cox leaned more on the bill being expaned and repealed. Ducey voters at 37% for expanded and 47% for repealed. Cox voters at 47% for expanded and 31% for repealed.
new_Vote <- Vote %>%
filter(rep_governor_vote_2019 == "John H. Cox"| rep_governor_vote_2019 == "Doug Ducey") %>%
mutate(favorhealth_2019 = ifelse(favorhealth_2019>10, NA,favorhealth_2019))
table(new_Vote$rep_governor_vote_2019, new_Vote$favorhealth_2019) %>%
prop.table(1)
##
## 1 2 3 4 8
## Doug Ducey 0.30051813 0.13471503 0.12435233 0.36269430 0.07772021
## John H. Cox 0.36947218 0.18687589 0.12838802 0.23537803 0.07988588
Ducey voters mainly lean on strongly favor at 30% and strongly oppose at 36%. Cox voters mainly lean on strongly favor at 37% and strongly oppose at 24%. This shows how Ducey voters may have mixed opinions on this topic since voters lean on opposite answers against each other. Lastly, Cox voters are more alligned with each other since they are higher in strongly favor than in strongly oppose, which depicts how they lean more in favor requiring all Americans having health insurance.
Vote %>%
select(rep_governor_vote_2019, fam_med_leave2019) %>%
filter(rep_governor_vote_2019 == "John H. Cox"| rep_governor_vote_2019 == "Doug Ducey") %>%
group_by(rep_governor_vote_2019, fam_med_leave2019) %>%
summarize(n=n()) %>%
mutate(percent=n/sum(n))
## # A tibble: 12 x 4
## # Groups: rep_governor_vote_2019 [2]
## rep_governor_vote_2019 fam_med_leave2019 n percent
## <chr> <dbl> <int> <dbl>
## 1 Doug Ducey 1 57 0.286
## 2 Doug Ducey 2 76 0.382
## 3 Doug Ducey 3 44 0.221
## 4 Doug Ducey 4 15 0.0754
## 5 Doug Ducey 8 4 0.0201
## 6 Doug Ducey NA 3 0.0151
## 7 John H. Cox 1 247 0.340
## 8 John H. Cox 2 253 0.348
## 9 John H. Cox 3 149 0.205
## 10 John H. Cox 4 39 0.0537
## 11 John H. Cox 8 14 0.0193
## 12 John H. Cox NA 24 0.0331
Voters of Ducey and Cox mainly lean on the favor category answers. Ducey voters at 29% for very important and 38% for somewhat important. Cox voters were at 34% for very important and 35% for somewhat important.
Vote %>%
select(rep_governor_vote_2019, healthcarelaw1_2019) %>%
filter(rep_governor_vote_2019 == "John H. Cox"| rep_governor_vote_2019 == "Doug Ducey") %>%
group_by(rep_governor_vote_2019, healthcarelaw1_2019) %>%
summarize(n=n()) %>%
mutate(percent=n/sum(n))
## # A tibble: 14 x 4
## # Groups: rep_governor_vote_2019 [2]
## rep_governor_vote_2019 healthcarelaw1_2019 n percent
## <chr> <dbl> <int> <dbl>
## 1 Doug Ducey 1 126 0.633
## 2 Doug Ducey 2 33 0.166
## 3 Doug Ducey 3 15 0.0754
## 4 Doug Ducey 4 13 0.0653
## 5 Doug Ducey 8 8 0.0402
## 6 Doug Ducey 98 1 0.00503
## 7 Doug Ducey NA 3 0.0151
## 8 John H. Cox 1 487 0.671
## 9 John H. Cox 2 111 0.153
## 10 John H. Cox 3 42 0.0579
## 11 John H. Cox 4 33 0.0455
## 12 John H. Cox 8 25 0.0344
## 13 John H. Cox 98 4 0.00551
## 14 John H. Cox NA 24 0.0331
Both voters of the governor candidates scored highest for very important for the prohibition at 63% for Ducey voters and 67% for Cox voters.
From the two sub-populations being compared, Cuomo and Garcia voters of dem_governor_vote_2019 had lower averages rates against Republicans and were strongly in favor that all Americans should be required to have health insurance. Meanwhile, Ducey and Cox voters of rep_governor_vote_2019 had mixed averages on their feelings on Democrats and mixed feelings on whether all Americans should be required to have health insurance. Both sub-populations had simularities in that they had higher perecentages for “very important” on the provision that prohibits health insurance companies from charging sick people more, leaned more on important for family medical leave, and believe that the health care reform bill that passed in 2010 should be expanded or repealed.