house_reps_regular

library(tidyverse)
library(here)
house_reps <- here("data-raw", "chronology-patched.csv") %>% 
  read_csv(col_types = cols(desk_number = col_integer()))

Start when Oregon is a state, February 14, 1859.

state_history <- house_reps %>% 
  filter(session_year >= 1859)

Use only regular sessions.

regular <- state_history %>% 
  filter(regular)

Split terms

split-terms.csv curated by hand contains legislators that share a session, e.g. one person leaves and is replaced by another:

splits <- read_csv(here("data-raw", "split-terms.csv")) %>% 
  rename_all(tolower)

For example, the first recorded split term

first_split <- splits %>% 
  left_join(regular) %>% 
  filter(split_id == min(split_id)) 

first_split %>% 
  select(session_year, legislator, split_order)

writeLines(first_split$notes)

Now remove second in seat:

second_seat <- splits %>% 
  filter(split_order == 2) %>% 
  select(session_year, legislator)

regular_first_in_seat <- regular %>% 
  anti_join(second_seat) 

regular_first_in_seat %>% 
  group_by(session_year) %>% 
  count()

Only use first party affiliation

regular_no_mixed_party <- regular_first_in_seat %>% 
  mutate(
    party_mixed = party %>% str_detect("/"), 
    party = ifelse(party_mixed, map_chr(str_split(party, "/"), 1), party)
  ) %>% 
  select(-party_mixed)

Output

house_reps_regular <- regular_no_mixed_party
usethis::use_data(house_reps_regular, overwrite = TRUE)


or-house-vis/history documentation built on May 15, 2019, 1:11 p.m.