Skip to content

Commit

Permalink
Merge pull request #25 from openjusticeok/census_population
Browse files Browse the repository at this point in the history
Fixed county_pop to use correct census data
  • Loading branch information
rcgentzler authored Jun 22, 2021
2 parents 6527e5e + 78baed0 commit 1cc3c64
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions R/county_pop.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,21 @@ county_pop <- function(years) {
d <- tibble()

for (y in years) {
d <- tidycensus::get_acs("county",
variables = c(pop = "B01003_001"),
state = "OK",
year = y) %>%
mutate(year = y) %>%
d <- tidycensus::get_estimates(product = "population",
year = y,
geography = "county",
state = "OK") |>
filter(variable == "POP") |>
mutate(year = y) |>
bind_rows(d)
}

d <- d %>%
mutate(court = NAME %>%
str_remove(" County.*") %>%
str_to_upper %>%
str_remove_all(" ")) %>%
select(court, year, pop = estimate)
d <- d |>
mutate(court = NAME |>
str_remove(" County.*") |>
str_to_upper() |>
str_remove_all(" ")) |>
select(court, year, pop = value)

return(d)
}
Expand Down

0 comments on commit 1cc3c64

Please sign in to comment.