Created
January 15, 2024 21:18
-
-
Save vgXhc/7346a72020824b77a3335c33b903f822 to your computer and use it in GitHub Desktop.
Demographics in Harambee
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| harambee_tracts <- c(44, 45, 67, 69, 70, 81, 106, 1856, 1857, 1860) | |
| milwaukee_tracts_2022 <- get_acs(geography = "tract", | |
| state = 55, | |
| county = "Milwaukee", | |
| table = "B02001", | |
| # summary_var = "B02001_001", | |
| year = 2022, | |
| output = "wide") | |
| milwaukee_tracts_2017 <- get_acs(geography = "tract", | |
| state = 55, | |
| county = "Milwaukee", | |
| table = "B02001", | |
| # summary_var = "B02001_001", | |
| year = 2017 , | |
| output = "wide") | |
| milwaukee_tracts_2017 <- milwaukee_tracts_2017 |> | |
| mutate(year = "2013-2017") | |
| milwaukee_tracts_2022 <- milwaukee_tracts_2022 |> | |
| mutate(year = "2018-2022") | |
| milwaukee_tracts <- rbind(milwaukee_tracts_2017, milwaukee_tracts_2022) | |
| milwaukee_tracts <- milwaukee_tracts |> | |
| mutate(tract = str_sub(GEOID, start = 6, end = 9), | |
| tract_numeric = as.numeric(tract)) | |
| milwaukee_tracts |> | |
| filter(tract_numeric %in% harambee_tracts) |> | |
| summarize(total_white = sum(B02001_002E), | |
| total_black = sum(B02001_003E), | |
| total = sum(B02001_001E), | |
| other_multiple = sum(B02001_007E, B02001_008E), | |
| .by = year) |> | |
| mutate(pct_white = total_white/total, | |
| pct_blk = total_black/total, | |
| pct_multiple_other = other_multiple/total) |> View() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment