![]() ![]() I am trying to figure out a way to reproduce a similar map for senate roll call votes. This is fine for mapping congressional districts on roll call votes by the house. Left_join(big_votes, by = c("state_abbrev", "district_code")) # Make the Party_Member_Vote variable a factor and change the order of its levels. #assigned 99, 98, or 1 in various circumstances. #Members who represent historical “at-large” districts are Party_Member_Vote = paste0(party_code, ': ', avote),ĭistrict_code = ifelse(district_code %in% c(98, 99), 0, district_code),ĭistrict_code = ifelse(n = 1 & district_code = 1, 0, district_code),ĭistrict_code = as.integer(district_code)) %>% Party_code = case_when(party_code = 100 ~ 'Dem', ![]() Mutate(avote = case_when(vote %in% c(1:3) ~ 'Yea', Left_join(votes$votes_long, by = c("id", "icpsr")) %>% # Download rollcall data from the Voteview database. Select(STATEFP, state_abbrev, district_code) # Join the congressional districts shapefile with the simple states dataframe weĭistrict_code = as.numeric(substr(ID, 11, 12))) %>% # Function to download a shapefile for any congressional district of your choice. The only thing different is that I provided a function that I found on another website to directly read a congressional district shapefile from the website where they are housed courtesy of the UCLA Political Science Department: # Workflow for mapping congressional district roll call voting resultsĭevtools::install_github("jaytimm/wnomadds") The idea would be to "stripe" the state in two different colors based on each of the Senator's party affiliation and vote type.īelow is a workflow that has already been created for viewing roll call voting results by congressional districts (not what I want, I want to do this for Senate voting), but I figured this would be a starting point or baseline for hoping to create a similar map for a roll call vote from the Senate. The problem I have is developing a workflow to color code a state (here I am using a simple sf dataframe of the US states) in this manner. This obviously involves coloring a state polygon based on the unique combination of the Senator's party affiliation and how they voted (2 senators per state). I am looking to ultimately render a map in Leaflet that shows the roll call voting results for a specific vote from the Senate. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |