Introduction

This report examines median household income across Davidson County and its six neighboring counties in Middle Tennessee using data from the 2024 American Community Survey (ACS), provided by the U.S. Census Bureau.

The analysis includes an interactive geographic map and dot plot illustrating differences in estimated median household income across the seven counties. The dot plot also displays margins of error associated with each estimate.

The analysis was conducted using R and the script provided in the Practical R Skills, Part 1 lesson.

Interactive Map of Median Household Income

The interactive map below displays estimated median household income across Davidson County and its six neighboring counties. Darker shades of blue represent higher median household income. Click on an individual county to view its income estimate and associated margin of error.

Median Household Income Comparison

The interactive dot plot below compares estimated median household income across the seven Nashville-area counties. Each dot represents a county’s estimated median household income, while the horizontal error bars represent the associated margins of error.

Hover over each data point to explore the individual county estimates.

Summary of County-Level Income Estimates

The following table provides the estimated median household income and associated margin of error for each county, ranked from highest to lowest median household income.

2024 ACS Five-Year Median Household Income Estimates
County Median Household Income Margin of Error
Williamson County, Tennessee $135,594 ±$4,044
Wilson County, Tennessee $95,839 ±$3,023
Sumner County, Tennessee $90,301 ±$2,629
Cheatham County, Tennessee $89,852 ±$6,619
Rutherford County, Tennessee $85,470 ±$1,909
Robertson County, Tennessee $83,047 ±$4,193
Davidson County, Tennessee $77,853 ±$1,253

Key Findings

The 2024 American Community Survey estimates reveal noticeable differences in median household income across the Nashville metropolitan area.

  • Williamson County has the highest estimated median household income at $135,594.
  • Davidson County has the lowest estimated median household income at $77,853.
  • The difference between the highest and lowest county estimates is $57,741.
  • Davidson County has the smallest margin of error at $1,253, while Cheatham County has the largest at $6,619.
  • Several counties have overlapping margins of error, demonstrating the importance of considering uncertainty when comparing income estimates.

These visualizations demonstrate how publicly available Census data can be used to explore regional economic and demographic patterns. This information can be particularly valuable for marketing, audience research, strategic communication, and community planning.

Data Source

U.S. Census Bureau. (2024). American Community Survey, 2024 five-year estimates. Variable DP03_0062: Median household income in the past 12 months.

https://data.census.gov/

Appendix A: Complete R Code

The following R code was used to retrieve, organize, analyze, and visualize median household income data from the 2024 American Community Survey. The code is adapted from the Practical R Skills, Part 1 lesson.

The Census API key is stored securely as an R environmental variable and is not included in this published document.

############################################################
# STEP 1: Load Packages
############################################################

if (!require("tidycensus")) install.packages("tidycensus")
if (!require("tidyverse")) install.packages("tidyverse")
if (!require("kableExtra")) install.packages("kableExtra")
if (!require("sf")) install.packages("sf")
if (!require("leaflet")) install.packages("leaflet")
if (!require("htmlwidgets")) install.packages("htmlwidgets")
if (!require("plotly")) install.packages("plotly")

library(tidycensus)
library(tidyverse)
library(kableExtra)
library(sf)
library(leaflet)
library(htmlwidgets)
library(plotly)

############################################################
# STEP 2: Verify Census API Key
############################################################

if (!nzchar(Sys.getenv("CENSUS_API_KEY"))) {
  stop("No Census API key was found.")
}

############################################################
# STEP 3: Configure Your Analysis
############################################################

acs_year <- 2024

state_abbrev <- "TN"

my_variable <- "DP03_0062"

geography_level <- "county"

selected_counties <- c(
  "Davidson",
  "Rutherford",
  "Williamson",
  "Cheatham",
  "Robertson",
  "Sumner",
  "Wilson"
)

############################################################
# STEP 4: Explore ACS Codebooks
############################################################

ProfileTables <- load_variables(
  acs_year,
  "acs5/profile"
)

############################################################
# STEP 5: Download ACS Data
############################################################

if (is.null(selected_counties)) {

  mydata <- get_acs(
    geography = geography_level,
    state = state_abbrev,
    year = acs_year,
    survey = "acs5",
    variables = my_variable,
    geometry = TRUE
  )

} else {

  mydata <- get_acs(
    geography = geography_level,
    state = state_abbrev,
    county = selected_counties,
    year = acs_year,
    survey = "acs5",
    variables = my_variable,
    geometry = TRUE
  )

}

############################################################
# STEP 6: Keep Needed Variables and Geometry
############################################################

mydata <- mydata |>
  select(
    Area = NAME,
    Variable = variable,
    Estimate = estimate,
    Margin_of_Error = moe,
    geometry
  )

############################################################
# STEP 7: Transform Coordinates for Leaflet
############################################################

mydata <- st_transform(
  mydata,
  crs = 4326
)

############################################################
# STEP 8: Download County Boundaries
############################################################

if (is.null(selected_counties)) {

  county_boundaries <- get_acs(
    geography = "county",
    state = state_abbrev,
    year = acs_year,
    survey = "acs5",
    variables = my_variable,
    geometry = TRUE
  )

} else {

  county_boundaries <- get_acs(
    geography = "county",
    state = state_abbrev,
    county = selected_counties,
    year = acs_year,
    survey = "acs5",
    variables = my_variable,
    geometry = TRUE
  )

}

county_boundaries <- st_transform(
  county_boundaries,
  4326
)

############################################################
# STEP 9: Sort Results from Highest to Lowest
############################################################

mydata <- mydata |>
  arrange(desc(Estimate))


############################################################
# STEP 11: Create Pop-Up Content
############################################################

mydata$popup <- paste0(
  "<strong>", mydata$Area, "</strong>",
  "<br><br>",
  "Estimate: $",
  format(mydata$Estimate, big.mark = ","),
  "<br>",
  "Plus/Minus: $",
  format(mydata$Margin_of_Error, big.mark = ",")
)

############################################################
# STEP 12: Build Color Palette
############################################################

qs <- unique(
  quantile(
    mydata$Estimate,
    probs = seq(0, 1, length.out = 6),
    na.rm = TRUE
  )
)

pal <- colorBin(
  palette = "Blues",
  domain = mydata$Estimate,
  bins = qs,
  pretty = FALSE
)

############################################################
# STEP 13: Create Choropleth Map
############################################################

AreaMap <- leaflet(mydata) |>
  addProviderTiles(
    providers$Esri.WorldTopoMap
  ) |>
  addPolygons(
    fillColor = ~pal(Estimate),
    fillOpacity = 0.5,
    color = "black",
    weight = 1,
    popup = ~popup
  )

if (geography_level != "county") {

  AreaMap <- AreaMap |>
    addPolygons(
      data = county_boundaries,
      fill = FALSE,
      color = "black",
      weight = 2,
      opacity = 1,
      group = "County Boundaries"
    )

}

AreaMap <- AreaMap |>
  addLegend(
    pal = pal,
    values = ~Estimate,
    title = "Median Household Income",
    labFormat = labelFormat(
      prefix = "$",
      big.mark = ","
    )
  )

AreaMap


############################################################
# STEP 14: Create Plotly Dot Plot
############################################################

plotdf <- mydata |>
  st_drop_geometry() |>
  mutate(
    point_color = pal(Estimate),

    y_ordered = reorder(
      Area,
      Estimate
    ),

    hover_text = paste0(
      Area,
      "\nEstimate: $",
      format(Estimate, big.mark = ","),
      "\nPlus/Minus: $",
      format(Margin_of_Error, big.mark = ",")
    )
  )

DotPlot <- plot_ly(
  data = plotdf,
  x = ~Estimate,
  y = ~as.character(y_ordered),
  type = "scatter",
  mode = "markers",
  showlegend = FALSE,
  marker = list(
    color = ~point_color,
    size = 8,
    line = list(
      color = "rgba(120,120,120,0.9)",
      width = 0.5
    )
  ),
  error_x = list(
    type = "data",
    array = ~Margin_of_Error,
    arrayminus = ~Margin_of_Error,
    color = "rgba(0,0,0,0.65)",
    thickness = 1
  ),
  text = ~hover_text,
  hovertemplate = "%{text}<extra></extra>"
) |>
  layout(
    title = list(
      text = paste0(
        "Median Household Income by County",
        "<br><sup>Error bars show ACS margins of error.</sup>"
      )
    ),
    xaxis = list(
      title = "Median Household Income",
      tickformat = "$,.0f",
      automargin = TRUE
    ),
    yaxis = list(
      title = "",
      automargin = TRUE,
      categoryorder = "array",
      categoryarray = levels(plotdf$y_ordered)
    ),
    margin = list(
      l = 200,
      r = 20,
      b = 60,
      t = 60,
      pad = 2
    )
  )

DotPlot


############################################################
# STEP 10: Display Results as a Table
############################################################

ResultsTable <- mydata |>
  st_drop_geometry() |>
  select(
    Area,
    Estimate,
    Margin_of_Error
  ) |>
  mutate(
    Estimate = scales::dollar(Estimate, accuracy = 1),
    Margin_of_Error = paste0(
      "±",
      scales::dollar(Margin_of_Error, accuracy = 1)
    )
  ) |>
  kbl(
    col.names = c(
      "County",
      "Median Household Income",
      "Margin of Error"
    ),
    align = c("l", "r", "r"),
    caption = "2024 ACS Five-Year Median Household Income Estimates"
  ) |>
  kable_styling(
    bootstrap_options = c("striped", "hover", "condensed"),
    full_width = FALSE,
    position = "center"
  )

ResultsTable