Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save elipousson/b3262650171e15409fe4324a8a125778 to your computer and use it in GitHub Desktop.
Save elipousson/b3262650171e15409fe4324a8a125778 to your computer and use it in GitHub Desktop.
library(getACS)
library(tidyverse)
vehicle_access_acs <- get_acs_tables(
"tract",
table = "B08201",
county = "Baltimore city",
state = "MD"
)
vehicle_access_district <- vehicle_access_acs |>
use_area_xwalk(
area_xwalk = filter(
baltimore_census_xwalk,
geography == "council district"
),
name_col = "name",
geography = "council district"
)
districts <- unique(vehicle_access_district$name)
vehicle_access_tbl_list <- map(
districts,
\(x) {
vehicle_access_district |>
filter(name == x) |>
filter_acs(indent == 1, line_number < 6) |>
select_acs() |>
gt_acs(
table = vehicle_access_district$table_id,
value_label = "Households",
column_title_label = "Access"
) |>
gt::tab_header(title = glue("How many households in City Council {x} have access to a vehicle?"))
}
)
tbl_docx <- officerExtras::read_docx_ext(allow_null = TRUE)
tbl_docx <- officerExtras::vec_add_to_body(
tbl_docx,
gt_object = vehicle_access_tbl_list,
.sep = officer::body_add_break
)
tbl_docx |>
officerExtras::write_officer("city_council_vehicle_access.docx")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment