The American Community Survey (ACS) provides estimates of demographic, social, and economic characteristics across the United States. This report uses the 2024 ACS 5-year estimates to examine two questions: how the percentage of graduate-degree holders varies among New York State counties, and how median household income varies among census tracts in New York City. In addition to identifying spatial patterns, the report considers the uncertainty associated with survey-based estimates.
The report uses the tidycensus package to retrieve ACS
data directly in R, ggplot2 to create static figures, and
plotly and mapview for interactive
visualizations.
Both analyses use the U.S. Census Bureau’s American Community Survey 2020–2024 5-year estimates. Part A uses counties in New York State, while Part B uses census tracts in the five boroughs of New York City. ACS estimates have margins of error, and small differences should not automatically be interpreted as meaningful differences.
Before knitting this document, install the required packages and register your free Census API key in the R console, not in this report:
# Run once in the R console; do not place your actual key in this file:
# tidycensus::census_api_key("YOUR_API_KEY", install = TRUE)
# Restart R after installing the key.
The ACS data profile variable DP02_0066P measures the
percentage of the relevant population with a graduate or professional
degree. The estimate and margin of error are retrieved together. We
rename the returned columns to make the subsequent code easier to
read.
# Retrieve county-level percentage estimates and margins of error.
county_degrees <- get_acs(
geography = "county",
variables = "DP02_0066P",
state = "NY",
year = 2024,
survey = "acs5",
output = "wide"
) %>%
transmute(
GEOID,
county = str_remove(NAME, ", New York$"),
pct_grad_degree = DP02_0066PE,
moe = DP02_0066PM
) %>%
# Exclude missing/suppressed values before ranking and plotting.
filter(!is.na(pct_grad_degree), !is.na(moe),
pct_grad_degree >= 0, moe >= 0)
# Examine the structure and number of counties returned.
glimpse(county_degrees)
## Rows: 62
## Columns: 4
## $ GEOID <chr> "36001", "36003", "36005", "36007", "36009", "36011", …
## $ county <chr> "Albany County", "Allegany County", "Bronx County", "B…
## $ pct_grad_degree <dbl> 22.8, 12.0, 8.3, 14.4, 9.8, 11.3, 11.3, 12.0, 8.6, 11.…
## $ moe <dbl> 0.8, 1.0, 0.3, 0.8, 0.8, 1.1, 0.8, 1.0, 1.0, 1.0, 1.4,…
nrow(county_degrees)
## [1] 62
To find an appropriate ACS variable, we first search the variable metadata. Median household income is measured in dollars; it is suitable for a choropleth because it is a summary statistic rather than a raw count.
# Search ACS variable labels before requesting tract-level data.
acs_variables <- load_variables(
year = 2024,
dataset = "acs5",
cache = TRUE
)
acs_variables %>%
filter(str_detect(label, regex("Median household income", ignore_case = TRUE))) %>%
select(name, label, concept) %>%
head(10)
## # A tibble: 10 × 3
## name label concept
## <chr> <chr> <chr>
## 1 B19013A_001 Estimate!!Median household income in the past 12 months … Median…
## 2 B19013B_001 Estimate!!Median household income in the past 12 months … Median…
## 3 B19013C_001 Estimate!!Median household income in the past 12 months … Median…
## 4 B19013D_001 Estimate!!Median household income in the past 12 months … Median…
## 5 B19013E_001 Estimate!!Median household income in the past 12 months … Median…
## 6 B19013F_001 Estimate!!Median household income in the past 12 months … Median…
## 7 B19013G_001 Estimate!!Median household income in the past 12 months … Median…
## 8 B19013H_001 Estimate!!Median household income in the past 12 months … Median…
## 9 B19013I_001 Estimate!!Median household income in the past 12 months … Median…
## 10 B19013_001 Estimate!!Median household income in the past 12 months … Median…
# Retrieve income estimates and Census tract boundaries for all five boroughs.
nyc_income <- get_acs(
geography = "tract",
variables = "B19013_001",
state = "NY",
county = c("Bronx", "Kings", "New York", "Queens", "Richmond"),
year = 2024,
survey = "acs5",
geometry = TRUE
) %>%
# Negative ACS sentinel values indicate unavailable/suppressed estimates.
mutate(income = if_else(estimate >= 0, as.numeric(estimate), NA_real_))
# Verify that this is an sf object and inspect the income distribution.
class(nyc_income)
## [1] "sf" "data.frame"
summary(nyc_income$income)
## Min. 1st Qu. Median Mean 3rd Qu. Max. NAs
## 11094 60632 82676 89600 108307 250001 128
The following tables identify the five counties with the highest and lowest estimated percentages of graduate-degree holders. The margins of error are included to provide context for these rankings.
highest_counties <- county_degrees %>%
arrange(desc(pct_grad_degree)) %>%
slice_head(n = 5) %>%
select(County = county, `Estimate (%)` = pct_grad_degree,
`MOE (percentage points)` = moe)
lowest_counties <- county_degrees %>%
arrange(pct_grad_degree) %>%
slice_head(n = 5) %>%
select(County = county, `Estimate (%)` = pct_grad_degree,
`MOE (percentage points)` = moe)
knitr::kable(highest_counties, digits = 1,
caption = "Five New York counties with the highest estimated graduate-degree percentages.")
| County | Estimate (%) | MOE (percentage points) |
|---|---|---|
| Tompkins County | 34.8 | 1.7 |
| New York County | 31.3 | 0.5 |
| Westchester County | 26.7 | 0.5 |
| Albany County | 22.8 | 0.8 |
| Nassau County | 22.8 | 0.4 |
knitr::kable(lowest_counties, digits = 1,
caption = "Five New York counties with the lowest estimated graduate-degree percentages.")
| County | Estimate (%) | MOE (percentage points) |
|---|---|---|
| Orleans County | 7.6 | 0.9 |
| Wyoming County | 7.6 | 0.9 |
| Fulton County | 7.7 | 1.1 |
| Lewis County | 8.1 | 1.0 |
| Bronx County | 8.3 | 0.3 |
Each point represents a county estimate, and each horizontal line shows its 90% ACS margin-of-error interval (estimate ± MOE). The counties are ordered by estimated percentage. Because New York has many counties, a tall figure is used to keep labels readable.
county_degrees <- county_degrees %>%
arrange(pct_grad_degree) %>%
mutate(county_ordered = factor(county, levels = county))
degree_plot <- ggplot(
county_degrees,
aes(x = pct_grad_degree, y = county_ordered)
) +
geom_segment(
aes(x = pmax(0, pct_grad_degree - moe),
xend = pct_grad_degree + moe,
yend = county_ordered),
linewidth = 0.6, color = "#6C93B5"
) +
geom_point(size = 1.9, color = "#173F65") +
labs(
title = "Graduate Degree Attainment Across New York Counties",
subtitle = "County estimates with 90% margins of error | ACS 2020–2024",
x = "Population with graduate or professional degree (%)",
y = NULL
) +
theme_minimal(base_size = 11) +
theme(panel.grid.major.y = element_blank())
degree_plot
Figure 1. Estimated percentage of the population with a graduate or professional degree by New York county, with ACS 90% margins of error. Source: U.S. Census Bureau, 2020–2024 ACS 5-year data profile DP02.
Does the margin-of-error plot work well for New York? The margin-of-error plot shows how graduate degree attainment varies across New York State counties. Ordering the counties by percentage makes it easier to compare estimates, although displaying all 62 counties makes the figure somewhat crowded. The margins of error also show that some county estimates are less precise than others, so small differences between counties should be interpreted cautiously. The interactive Plotly version helps address the readability issue by allowing users to explore individual estimates.
The interactive version allows readers to hover over counties to inspect the estimates and margins of error. It uses the same underlying data as Figure 1.
# Convert the existing ggplot to an interactive Plotly chart.
# A fixed height keeps the county names readable in HTML.
plotly::ggplotly(degree_plot, height = 1050) %>%
layout(title = list(text = "Interactive County Graduate Degree Estimates"))
Figure 2. Interactive county-level graduate degree estimates and ACS margins of error. Hover over points and intervals to explore individual counties. Source: U.S. Census Bureau, 2020–2024 ACS 5-year data profile DP02.
This interactive map shows the estimated median household income for each Census tract. Readers can zoom into individual neighborhoods and inspect values. Tracts without a valid income estimate are shown separately from those with available data.
# Mapview accepts sf polygons directly and provides interactive navigation.
mapview::mapview(
nyc_income,
zcol = "income",
layer.name = "Median household income ($)",
legend = TRUE,
na.color = "#D9D9D9",
map.types = "Esri.WorldTopoMap"
)
Figure 3. Interactive map of median household income by New York City Census tract. Zoom and select tracts to explore local variation. Gray areas indicate missing or unavailable estimates. Source: U.S. Census Bureau, 2020–2024 ACS 5-year table B19013.
Because median household income is already a standardized summary measure, a choropleth is appropriate. A continuous color scale emphasizes differences across census tracts.
income_map <- ggplot(nyc_income) +
geom_sf(aes(fill = income), color = NA) +
scale_fill_viridis_c(
option = "viridis",
labels = label_dollar(),
na.value = "grey85"
) +
labs(
title = "Median Household Income Across New York City",
subtitle = "2020–2024 ACS 5-year estimates | Census tracts",
fill = "Median income"
) +
coord_sf(datum = NA) +
theme_void(base_size = 12) +
theme(
plot.title = element_text(face = "bold"),
legend.position = "right"
)
income_map
Figure 4. Median household income by Census tract across the five boroughs of New York City. Brighter colors indicate higher estimated income; gray denotes missing values. Source: U.S. Census Bureau, 2020–2024 ACS 5-year table B19013.
The maps illustrate how median household income varies across New York City, with noticeable differences between census tracts, even within the same borough. The interactive map is particularly helpful for exploring these differences at a neighborhood scale, while the static map provides a clearer overview of the citywide distribution. However, these values represent estimated median household incomes for entire census tracts rather than individual households. Because the ACS is based on survey estimates, differences between neighboring tracts should also be considered alongside their margins of error.
This lab demonstrated how ACS data can be used to examine differences in education and income across geographic areas. The county analysis highlighted variation in graduate degree attainment and the importance of considering margins of error when comparing estimates. The NYC maps showed how income patterns can vary at a much smaller geographic scale. Using both static and interactive visualizations made it easier to identify broad patterns while also exploring individual locations in more detail.