
Tidy Tuesday: The worst plumbing gaps are in counties the 1-year Census skips
Preface
This one comes from the archive: the 2025-01-28 TidyTuesday week on water insecurity. The data was built from the USGS Vizlab post Mapping water insecurity in R with tidycensus (December 2024), whose code is on GitHub. That post is a good tidycensus walkthrough. It maps the share of households lacking complete plumbing across the Western US and compares 2022 with 2023.
The TidyTuesday file scales the USGS code up to every county, and that’s where it hits a wall. The USGS post used the 1-year American Community Survey, which only publishes counties with 65,000 or more people. The places where plumbing is actually missing tend to be small, remote and rural, so they fall outside it.
My twist was to use tidycensus to pull the 5-year ACS for all 3,222 counties and county equivalents (including Puerto Rico’s 78 municipios), count renters as well as owners, and carry the Census Bureau’s margins of error through to the chart.
Loading necessary packages
Code
library(tidyverse)
library(tidycensus)
library(sf)
library(scales)
library(paletteer)
library(patchwork)
options(tigris_use_cache = TRUE)
`%ni%` <- Negate(`%in%`)
# tidycensus reads the key from the CENSUS_API_KEY environment variable.
# Get one free at https://api.census.gov/data/key_signup.htmlLoad raw data
First, the TidyTuesday file as published. The geometry column is stored as R code in text, and I don’t need it, so I skip it on read.
tt_2023 <- readr::read_csv(
"https://raw.githubusercontent.com/rfordatascience/tidytuesday/main/data/2025/2025-01-28/water_insecurity_2023.csv",
col_select = -geometry
)Then the same table, B25049 (“Tenure by plumbing facilities”), straight from the Census API. I pull it once from the 1-year survey, to match the TidyTuesday file, and once from the 5-year survey. With geometry = TRUE, tidycensus attaches the county shapes through tigris, and shift_geometry() moves Alaska, Hawaii and Puerto Rico under the lower 48.
plumbing_vars <- c(
households = "B25049_001", # occupied housing units
owner_lack = "B25049_004", # owner occupied, lacking complete plumbing
renter_lack = "B25049_007", # renter occupied, lacking complete plumbing
pop = "B01003_001" # total population
)
acs1 <- get_acs(
geography = "county", variables = plumbing_vars,
year = 2023, survey = "acs1", output = "wide"
)
acs5 <- get_acs(
geography = "county", variables = plumbing_vars,
year = 2023, survey = "acs5", output = "wide",
geometry = TRUE, resolution = "20m"
) %>%
tigris::shift_geometry()
# Non-overlapping earlier window, for a change check
acs5_2018 <- get_acs(
geography = "county", variables = plumbing_vars,
year = 2018, survey = "acs5", output = "wide"
)
# Tribal areas cut across county lines, so pull them as their own geography
tribal <- get_acs(
geography = "american indian area/alaska native area/hawaiian home land",
variables = plumbing_vars, year = 2023, survey = "acs5", output = "wide"
)
states <- tigris::states(cb = TRUE, resolution = "20m", year = 2023) %>%
filter(GEOID %ni% c("60", "66", "69", "78")) %>%
tigris::shift_geometry()Exploratory data analysis
What the TidyTuesday number measures
tt_2023 %>%
summarise(
counties = n(),
states_and_pr = n_distinct(str_sub(geoid, 1, 2)),
missing_pct = sum(is.na(percent_lacking_plumbing))
)# A tibble: 1 × 3
counties states_and_pr missing_pct
<int> <int> <int>
1 854 52 1
# Rebuild the TidyTuesday percent from our own 1-year pull
tt_check <- acs1 %>%
transmute(GEOID, rebuilt = owner_lackE / popE * 100) %>%
inner_join(tt_2023, by = c("GEOID" = "geoid"))
tt_check %>%
summarise(
matched = n(),
max_abs_diff = max(abs(rebuilt - percent_lacking_plumbing), na.rm = TRUE)
)# A tibble: 1 × 2
matched max_abs_diff
<int> <dbl>
1 854 1.11e-16
Our 1-year pull reproduces the TidyTuesday column exactly, which confirms how it was built: owner-occupied households lacking plumbing divided by total population. That mixes two units. The numerator counts households and the denominator counts people, and renters are left out of the numerator completely. The column is labeled “percent of population”, but it’s neither a share of people nor a share of households.
The better measure comes from the same table. Lacking plumbing is owner_lack + renter_lack, out of households. tidycensus has helpers for the error that comes with it: moe_sum() for the numerator and moe_prop() for the ratio.
add_rate <- function(df) {
df %>%
rowwise() %>%
mutate(
lacking = owner_lackE + renter_lackE,
lacking_moe = moe_sum(c(owner_lackM, renter_lackM), c(owner_lackE, renter_lackE))
) %>%
ungroup() %>%
mutate(
rate = lacking / householdsE,
rate_moe = moe_prop(lacking, householdsE, lacking_moe, householdsM),
cv = (rate_moe / 1.645) / rate
)
}
counties <- acs5 %>%
add_rate() %>%
mutate(in_acs1 = GEOID %in% acs1$GEOID)
counties_tbl <- st_drop_geometry(counties)
cat(sprintf("counties: %d rows, %d in the 1-year ACS\n", nrow(counties_tbl), sum(counties_tbl$in_acs1)))counties: 3222 rows, 854 in the 1-year ACS
stopifnot("County data has 0 rows" = nrow(counties_tbl) > 0)
counties_tbl %>%
select(rate, rate_moe, householdsE) %>%
summary() rate rate_moe householdsE
Min. :0.000000 Min. :0.0003119 Min. : 17
1st Qu.:0.001988 1st Qu.:0.0021682 1st Qu.: 4268
Median :0.003767 Median :0.0041815 Median : 10200
Mean :0.006493 Mean :0.0069444 Mean : 39951
3rd Qu.:0.007431 3rd Qu.:0.0076644 3rd Qu.: 26346
Max. :0.334916 Max. :0.8823529 Max. :3390254
# How far off is the TidyTuesday measure for the counties it does cover?
acs1_rates <- acs1 %>%
add_rate() %>%
mutate(tt_style = owner_lackE / popE)
acs1_rates %>%
filter(tt_style > 0) %>%
summarise(median_ratio = median(rate / tt_style))# A tibble: 1 × 1
median_ratio
<dbl>
1 3.86
Nationally, 0.40% of occupied households (519,469) lack complete plumbing. Renters make up 47% of them, and the TidyTuesday measure drops all of them. In the counties both sources cover, the household rate is a median 3.9 times the TidyTuesday number. Apache County, Arizona, top of the TidyTuesday list at 3.91%, is at 12.7% of households.
Where the gaps are
The 1-year survey covers 854 counties, where 85% of US households live. The other 2,368 counties hold only 15% of households, but 23% of the households without plumbing.
davos <- rev(as.character(paletteer::paletteer_c("scico::davos", n = 8)))[2:8]
ink <- "#1C2B39"
paper <- "#F7F6F2"
no_data <- "#E3E0D8"
rate_breaks <- c(0, 0.0025, 0.005, 0.01, 0.02, 0.05, 0.10, 1)
rate_labels <- c("< 0.25%", "0.25–0.5%", "0.5–1%", "1–2%", "2–5%", "5–10%", "10%+")
bin_rate <- function(x) {
cut(x, rate_breaks, labels = rate_labels, include.lowest = TRUE, right = FALSE) %>%
fct_na_value_to_level("No estimate")
}
bin_cols <- c(set_names(davos, rate_labels), "No estimate" = no_data)
tt_map <- counties %>%
select(GEOID) %>%
left_join(tt_2023 %>% select(geoid, percent_lacking_plumbing), by = c("GEOID" = "geoid")) %>%
mutate(bin = bin_rate(percent_lacking_plumbing / 100))
acs5_map <- counties %>%
mutate(bin = bin_rate(rate))
stopifnot("Map data has 0 rows" = nrow(tt_map) > 0, nrow(acs5_map) > 0)
callouts <- counties %>%
filter(GEOID %in% c("02050", "04001")) %>%
st_point_on_surface() %>%
mutate(
x = st_coordinates(.)[, 1],
y = st_coordinates(.)[, 2],
label = case_when(
GEOID == "02050" ~ paste0("Alaska: ", alaska_top10, " of the\n10 highest-rate counties"),
GEOID == "04001" ~ "Navajo Nation area:\nApache, Navajo and\nMcKinley counties"
),
lx = x + if_else(GEOID == "02050", 400000, -1250000),
ly = y + if_else(GEOID == "02050", -450000, -650000),
hj = if_else(GEOID == "02050", 0, 1)
) %>%
st_drop_geometry()
map_panel <- function(data, title, subtitle, show_callouts = FALSE, show_legend = TRUE) {
p <- ggplot(data) +
geom_sf(aes(fill = bin), color = NA, show.legend = TRUE) +
geom_sf(data = states, fill = NA, color = "white", linewidth = 0.25) +
scale_fill_manual(
values = bin_cols, drop = FALSE,
name = "Share lacking complete plumbing"
) +
guides(fill = guide_legend(nrow = 1, title.position = "top", label.position = "bottom", keywidth = unit(1.6, "cm"))) +
labs(title = title, subtitle = subtitle) +
theme_void(base_size = 12) +
theme(
plot.title = element_text(face = "bold", color = ink, size = 13),
plot.subtitle = element_text(color = "grey30", size = 10.5, margin = margin(b = 4)),
legend.position = if (show_legend) "bottom" else "none",
legend.title = element_text(color = ink, size = 10, face = "bold"),
legend.text = element_text(color = ink, size = 9)
)
if (show_callouts) {
p <- p +
geom_segment(data = callouts, aes(x = x, y = y, xend = lx, yend = ly), color = ink, linewidth = 0.35) +
geom_label(
data = callouts, aes(x = lx, y = ly, label = label, hjust = hj),
size = 3.1, color = ink, fill = alpha(paper, 0.9),
label.size = 0, lineheight = 0.95
) +
geom_point(data = callouts, aes(x = x, y = y), shape = 21, size = 2.6, stroke = 0.9, color = ink, fill = NA)
}
p
}
p_top <- map_panel(
tt_map,
"As published: 1-year ACS, owners ÷ people",
paste0(comma(sum(!is.na(tt_map$percent_lacking_plumbing))), " counties with an estimate. Renters aren't counted and the denominator is people, so everything reads low"),
show_legend = FALSE
)
p_bottom <- map_panel(
acs5_map,
"Re-pulled: 5-year ACS, all households ÷ households",
paste0("All ", comma(nrow(acs5_map)), " counties and municipios. The deepest blues are in places the 1-year survey doesn't cover"),
show_callouts = TRUE
)
(p_top / p_bottom) +
plot_annotation(
title = "The worst plumbing gaps are in counties the 1-year Census skips",
caption = "Data: US Census Bureau, ACS table B25049 (2023 1-year; 2019–2023 5-year) via tidycensus. TidyTuesday 2025-01-28.\nMethod after USGS Vizlab, 'Mapping water insecurity in R with tidycensus' (2024).",
theme = theme(
plot.title = element_text(face = "bold", size = 17, color = ink),
plot.caption = element_text(color = "grey40", size = 8.5, hjust = 0),
plot.background = element_rect(fill = paper, color = NA)
)
) &
theme(plot.background = element_rect(fill = paper, color = NA))
On the top map, the counties that matter most are grey. Rural Alaska, where most villages sit off the road network, is almost entirely missing, along with the reservation counties of South Dakota and most of the rural Southwest. On the bottom map they’re the darkest places in the country.
The ten worst, and how sure the survey is
9 of the 10 counties with the highest rates, and 21 of the top 25, have no 1-year estimate. 9 of the top 10 are in Alaska. The 5-year survey reaches small places by pooling five years of responses, and the trade-off shows in the error bars.
coverage_cols <- c(
"Has a 1-year estimate" = davos[4],
"Only in the 5-year ACS" = davos[7]
)
top25 <- ranked %>%
slice_head(n = 25) %>%
mutate(
coverage = if_else(in_acs1, names(coverage_cols)[1], names(coverage_cols)[2]),
coverage = factor(coverage, levels = names(coverage_cols)),
label = str_replace(NAME, " (County|Census Area|Borough|City and Borough), ", ", "),
label = fct_reorder(label, rate),
lo = pmax(rate - rate_moe, 0),
hi = rate + rate_moe
)
stopifnot("Plot data has 0 rows" = nrow(top25) > 0)
ggplot(top25, aes(y = label)) +
geom_vline(xintercept = us_rate, linetype = "22", color = ink, linewidth = 0.4) +
geom_linerange(aes(xmin = lo, xmax = hi, color = coverage), linewidth = 1.1, alpha = 0.45) +
geom_point(aes(x = rate, color = coverage), size = 3.2) +
geom_text(
aes(x = hi, label = paste0(comma(lacking), " of ", comma(householdsE))),
hjust = -0.12, size = 2.9, color = "grey35"
) +
annotate(
"text", x = us_rate + 0.004, y = 24, hjust = 0, size = 3.1, color = ink,
label = paste0("US: ", percent(us_rate, accuracy = 0.01))
) +
scale_color_manual(values = coverage_cols, name = NULL) +
scale_x_continuous(
labels = label_percent(), limits = c(0, 0.45),
breaks = seq(0, 0.4, 0.1), expand = expansion(mult = c(0, 0.02))
) +
labs(
title = paste0(top10_missing, " of the 10 worst-off counties have no 1-year estimate"),
subtitle = "Share of occupied households lacking complete plumbing, with 90% margins of error.\nLabels give households lacking plumbing out of all occupied households",
x = "Households lacking complete plumbing",
y = NULL,
caption = "Data: ACS 2019–2023 5-year estimates, table B25049, via tidycensus."
) +
theme_minimal(base_size = 12) +
theme(
plot.background = element_rect(fill = paper, color = NA),
panel.grid.minor = element_blank(),
panel.grid.major.y = element_blank(),
panel.grid.major.x = element_line(color = "grey85", linewidth = 0.3),
plot.title = element_text(face = "bold", size = 15, color = ink),
plot.title.position = "plot",
plot.subtitle = element_text(color = "grey30", margin = margin(b = 8)),
plot.caption = element_text(color = "grey45", size = 8.5, hjust = 0),
plot.caption.position = "plot",
axis.text.y = element_text(color = ink, size = 9.5),
legend.position = "top",
legend.justification = "left"
)
The margins are wide for the smallest places. Yukon-Koyukuk has about 2,300 households, so its rate is a rough figure. But even the low end of every bar in the top 10 is many times the national rate. The ranking at the very top isn’t noise.
At the other end of the distribution, the uncertainty does matter. Among counties with any households lacking plumbing, 82% of the estimates have a coefficient of variation above 30%, a common cutoff for “use with caution”. That’s because when only a handful of households lack plumbing, a handful of survey responses decides the number. For most of the bottom map, the honest reading is “low”, not a precise percentage.
Tribal lands, counted directly
County lines blur the Navajo Nation story, because the reservation spans parts of Arizona, New Mexico and Utah and several counties. tidycensus can pull tribal areas as a geography of their own. The Navajo Nation reservation and trust land has 8,610 households lacking complete plumbing, 17.1% of its households and 1.7% of all such households in the country. The Hopi Reservation, which the Navajo Nation surrounds, is at 21.4%.
One county in the top 25 stands out: Adams County, Indiana, at 9.1%. It has a large Amish community, where going without some modern plumbing can be a choice. But Holmes County, Ohio, LaGrange County, Indiana, and Lancaster County, Pennsylvania, also home to large Amish settlements, are all at or below 0.5%. So I’d treat it as a lead to check, not an explanation.
Has it changed?
The README asks how 2022 compares with 2023. Two single years of survey data mix real change with sampling noise, and only cover the large counties. Two non-overlapping 5-year windows give a steadier, complete answer. Nationally the rate went from 0.41% in 2014–2018 to 0.40% in 2019–2023. So at the national level, barely any change. One wrinkle: the ACS dropped the flush toilet from its plumbing definition in 2016, partway through the earlier window, so the two periods don’t measure quite the same thing.
Final thoughts and takeaways
The USGS post is a good template, and it’s honest about its scope: Western states, 1-year data. The trouble starts when that template is pointed at every county. The 1-year survey’s population cutoff hides exactly the places a plumbing map exists to find. Swapping survey = "acs1" for survey = "acs5", adding renters, and dividing by households instead of people changes what the map shows. Instead of a handful of Arizona and New Mexico counties at 1–5%, the darkest places are mostly rural Alaska and the Navajo Nation, at 10–34%.
If a county map has a lot of grey, check the survey before checking the data. get_acs() defaults to survey = "acs5" for a reason. Use 1-year data when you need the most recent year for large places, and 5-year data when you need everywhere. Then keep the moe columns: moe_sum(), moe_prop() and moe_ratio() make carrying them through a two-line job.
Caveats: “Lacking complete plumbing” is the ACS definition (hot and cold running water and a bath or shower in the unit). It doesn’t capture water quality, unreliable supply or unaffordable bills, which are also forms of water insecurity. The 5-year estimates describe 2019–2023 as a period, not 2023. The Alaska boundaries are census areas, not villages, and a borough-level rate can hide villages with full service next to villages hauling water. And none of this says why plumbing is missing. Cost, remoteness, permafrost and choice all show up in the same number.