# Seattle-area countiesseattle_counties <-c("King", "Snohomish", "Pierce", "Kitsap", "Chelan", "Kittitas")wa_counties <-counties(state =53, year =2019)seattle_water <-tibble(county = seattle_counties) %>%# Get each county individuallymutate(water =map(county, ~area_water("WA", .x, year =2019))) %>%unnest(water) %>%st_sf() # Make the geometry column magical again
Number of people who reenrolled:
Code
riders_final %>%filter(times ==1) %>%count(ever_reenroll) %>%mutate(prop = n /sum(n))## # A tibble: 2 × 3## ever_reenroll n prop## <lgl> <int> <dbl>## 1 FALSE 82943 0.849## 2 TRUE 14750 0.151
Plot rider count for fun
Code
# Filter the tigris datacounty_shapes <- wa_counties %>%filter(NAME %in% seattle_counties)water_plot <- seattle_water %>%filter(AWATER >=1000000)# Join the ACS data to the rider block groupsrider_bgs <- riders_final %>%count(FIPS, name ="n_riders") %>%left_join(acs_wa, by =c("FIPS"="GEOID"))# Join boundaries to observed rider block groupsgeo_rider_bgs <- rider_bgs %>%left_join(select(wa_bgs, GEOID, geometry), by =c("FIPS"="GEOID")) %>%st_sf() %>%# Make the geometry column magical again# Truncate the number of ridersmutate(n_riders_trunc =ifelse(n_riders >=500, 500, n_riders))# Plotggplot() +geom_sf(data = county_shapes, fill ="grey90") +geom_sf(data = water_plot, fill ="lightblue") +geom_sf(data = geo_rider_bgs, aes(fill = n_riders_trunc), size =0) +scale_fill_viridis_c(option ="plasma") +labs(title ="Greater Seattle Area", fill ="Number of riders") +theme_void() +theme(legend.position ="bottom")