I am interested in how Republicans and Democrats (partyreg_baseline) differ about the immigrants. I will be comparing them based on:
immi_naturalize_2019: How they favor or oppose provide a legal way for illegal immigrants already in the United States to become U.S. citizens?
immi_makedifficult_2019: What they think it should be easier or harder for foreigners to immigrate to the US legally than it is currently?
immi_muslim_2019: How they favor or oppose temporarily banning Muslims immigrants from other countries from entering the United States?
ft_immig_2017: How they feel abouts immigrants?
Loading the necessary packages. Importing data into R and named it Voter_Data.
library(readr)
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
Voter_Data = read_csv("/Users/sakif/Desktop/Data 333/Voter Data 2019.csv")
##
## ── 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
## )
## ℹ Use `spec()` for the full column specifications.
## Warning: 800 parsing failures.
## row col expected actual file
## 2033 weight_18_24_2018 1/0/T/F/TRUE/FALSE .917710168467982 '/Users/sakif/Desktop/Data 333/Voter Data 2019.csv'
## 2828 weight_18_24_2018 1/0/T/F/TRUE/FALSE 1.41022291345592 '/Users/sakif/Desktop/Data 333/Voter Data 2019.csv'
## 4511 weight_18_24_2018 1/0/T/F/TRUE/FALSE 1.77501243840922 '/Users/sakif/Desktop/Data 333/Voter Data 2019.csv'
## 7264 weight_18_24_2018 1/0/T/F/TRUE/FALSE 1.29486870319614 '/Users/sakif/Desktop/Data 333/Voter Data 2019.csv'
## 7277 weight_18_24_2018 1/0/T/F/TRUE/FALSE 1.44972719707603 '/Users/sakif/Desktop/Data 333/Voter Data 2019.csv'
## .... ................. .................. ................ ...................................................
## See problems(...) for more details.
Voter_Data
## # A tibble: 9,548 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
## 7 0.456 0.378 NA NA NA
## 8 1.05 0.993 0.965 NA NA
## 9 0.478 1.03 NA NA NA
## 10 0.417 0.377 0.516 NA NA
## # … with 9,538 more rows, and 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>, …
The partyreg_baseline variable will break up my respondents into two groups (Democrat & Republican), and the other four variables represent the behaviors/attitudes which I will be investigating as I compare republicans to democrats. So I will do the following recoding to make the new variable called Immigrants_Data. Where it will be on two groups, where it will show their behaviors/attitude about immigrants.
Immigrants_Data = Voter_Data %>%
mutate(Political_Party = ifelse(partyreg_baseline == 1 , "Democrat",
ifelse(partyreg_baseline == 2, "Republican", NA)),
Immigrants_Naturalize = ifelse(immi_naturalize_2019 == 1, "Favor",
ifelse(immi_naturalize_2019 == 2, "Oppose",
ifelse(immi_naturalize_2019 == 8, "Don't know", NA))),
Immigrants_Hardness = ifelse(immi_makedifficult_2019 == 1, "Much easier",
ifelse(immi_makedifficult_2019 == 3, "No change",
ifelse(immi_makedifficult_2019 == 5, "Much harder",
ifelse(immi_makedifficult_2019 == 8, "Don't know", NA)))),
Banning_Muslims = ifelse(immi_muslim_2019 == 1, "Strongly favor",
ifelse(immi_muslim_2019 == 4, "Strongly oppose",
ifelse(immi_muslim_2019 == 8, "Don't know", NA))),
Feeling_About_Immigrants = ifelse(ft_immig_2017 > 100, NA, ft_immig_2017)) %>%
select(Political_Party, Immigrants_Naturalize, Immigrants_Hardness, Banning_Muslims, Feeling_About_Immigrants) %>%
filter(!is.na(Political_Party), !is.na(Immigrants_Naturalize), !is.na(Immigrants_Hardness), !is.na(Banning_Muslims), !is.na(Feeling_About_Immigrants))
Immigrants_Data
## # A tibble: 897 x 5
## Political_Party Immigrants_Natu… Immigrants_Hard… Banning_Muslims
## <chr> <chr> <chr> <chr>
## 1 Democrat Favor No change Strongly oppose
## 2 Democrat Favor Much easier Strongly oppose
## 3 Democrat Favor Much easier Strongly oppose
## 4 Democrat Favor No change Strongly oppose
## 5 Republican Oppose Much harder Strongly favor
## 6 Republican Don't know Much harder Strongly favor
## 7 Democrat Favor Much easier Strongly oppose
## 8 Republican Favor Much easier Don't know
## 9 Republican Oppose Much harder Strongly favor
## 10 Democrat Favor Much easier Strongly oppose
## # … with 887 more rows, and 1 more variable: Feeling_About_Immigrants <dbl>