The table below shows Nashville-area counties sorted in descending order by percent population change between the earlier and current population estimates. These data, obtained from the U.S. Census Bureau’s American Community Survey (ACS), provide a clear picture of how population growth has varied across counties in the Nashville region. Counties with the highest percent change experienced the fastest rates of growth, suggesting increased residential development and migration into those areas. In contrast, counties with lower percent change values grew more slowly during the same period. More information can be found on the ACS Website.

Population Data
County CurrentPop EarlierPop Region Change
Cannon 14818 13958 Non-doughnut 860
Cheatham 41829 39087 Doughnut 2742
Davidson 715388 598184 Davidson 117204
Dickson 55983 51608 Non-doughnut 4375
Hickman 25436 24561 Non-doughnut 875
Macon 26240 23261 Non-doughnut 2979
Maury 107791 88738 Non-doughnut 19053
Robertson 75539 67517 Doughnut 8022
Rutherford 360646 292425 Doughnut 68221
Smith 20389 19389 Non-doughnut 1000
Sumner 204424 174773 Doughnut 29651
Trousdale 11957 10131 Non-doughnut 1826
Williamson 260351 208242 Doughnut 52109
Wilson 158805 129918 Doughnut 28887
County Change Data
County Change
Davidson 117204
Rutherford 68221
Williamson 52109
Sumner 29651
Wilson 28887
Maury 19053
Robertson 8022
Dickson 4375
Macon 2979
Cheatham 2742
Trousdale 1826
Smith 1000
Hickman 875
Cannon 860
Davidson and Doughnut Counties
County CurrentPop EarlierPop Region Change
Davidson 715388 598184 Davidson 117204
Rutherford 360646 292425 Doughnut 68221
Williamson 260351 208242 Doughnut 52109
Sumner 204424 174773 Doughnut 29651
Wilson 158805 129918 Doughnut 28887
Robertson 75539 67517 Doughnut 8022
Cheatham 41829 39087 Doughnut 2742
Regional Population Summary
Region CurrentPop EarlierPop Change
Davidson 715388 598184 117204
Doughnut 1101594 911962 189632
Non-doughnut 262614 231646 30968
Population Data with Percent Change
County CurrentPop EarlierPop Region Change Percent_change
Williamson 260351 208242 Doughnut 52109 0.250
Rutherford 360646 292425 Doughnut 68221 0.233
Wilson 158805 129918 Doughnut 28887 0.222
Maury 107791 88738 Non-doughnut 19053 0.215
Davidson 715388 598184 Davidson 117204 0.196
Trousdale 11957 10131 Non-doughnut 1826 0.180
Sumner 204424 174773 Doughnut 29651 0.170
Macon 26240 23261 Non-doughnut 2979 0.128
Robertson 75539 67517 Doughnut 8022 0.119
Dickson 55983 51608 Non-doughnut 4375 0.085
Cheatham 41829 39087 Doughnut 2742 0.070
Cannon 14818 13958 Non-doughnut 860 0.062
Smith 20389 19389 Non-doughnut 1000 0.052
Hickman 25436 24561 Non-doughnut 875 0.036

Code:

# ==================================================
# Step 1: Install and load required packages
# ==================================================
required_packages <- c("tidyverse", "knitr", "kableExtra")

for (pkg in required_packages) {
  if (!requireNamespace(pkg, quietly = TRUE)) {
    install.packages(pkg)
  }
}

library(tidyverse)
library(knitr)
library(kableExtra)

# ==================================================
# Step 2: Create a vector of county names
# ==================================================
County <- c("Cannon", "Cheatham", "Davidson", "Dickson", "Hickman", "Macon",
            "Maury", "Robertson", "Rutherford", "Smith", "Sumner", "Trousdale",
            "Williamson", "Wilson")

# ==================================================
# Step 3: Create a vector of current population values
# ==================================================
CurrentPop <- c(14818, 41829, 715388, 55983, 25436, 26240,
                107791, 75539, 360646, 20389, 204424,
                11957, 260351, 158805)

# ==================================================
# Step 4: Create a vector of earlier population values
# ==================================================
EarlierPop <- c(13958, 39087, 598184, 51608, 24561, 23261,
                88738, 67517, 292425, 19389, 174773,
                10131, 208242, 129918)

# ==================================================
# Step 5: Create a vector of region classifications
# ==================================================
Region <- c("Non-doughnut", "Doughnut", "Davidson", "Non-doughnut",
            "Non-doughnut", "Non-doughnut", "Non-doughnut",
            "Doughnut", "Doughnut", "Non-doughnut",
            "Doughnut", "Non-doughnut", "Doughnut", "Doughnut")

# ==================================================
# Step 6: Combine vectors into a Population data frame
# ==================================================
Population <- data.frame(
  County,
  CurrentPop,
  EarlierPop,
  Region
)

# ==================================================
# Step 7: Add a Change variable showing population
#         growth
# ==================================================
Population <- Population %>%
  mutate(Change = CurrentPop - EarlierPop)

# ==================================================
# Step 8: Display the updated Population data frame
# ==================================================
Population

# ==================================================
# Step 9: Create a Change_only data frame containing
#         only the County and Change variables
# ==================================================
Change_only <- Population %>%
  select(County, Change)

# ==================================================
# Step 10: Sort Change_only by Change in descending
#          order
# ==================================================
Change_only <- Change_only %>%
  arrange(desc(Change))

# ==================================================
# Step 11: Display the Change_only data frame
# ==================================================
Change_only

# ==================================================
# Step 12: Create a Doughnut data frame containing
#          only Davidson and Doughnut regions
# ==================================================
Doughnut <- Population %>%
  filter(Region %in% c("Davidson", "Doughnut"))

# ==================================================
# Step 13: Sort Doughnut by Change in descending
#          order
# ==================================================
Doughnut <- Doughnut %>%
  arrange(desc(Change))

# ==================================================
# Step 14: Display the Doughnut data frame
# ==================================================
Doughnut

# ==================================================
# Step 15: Create a Summary data frame containing
#          population totals by Region
# ==================================================
Summary <- Population %>%
  group_by(Region) %>%
  summarize(
    CurrentPop = sum(CurrentPop),
    EarlierPop = sum(EarlierPop),
    Change = sum(Change),
    .groups = "drop"
  )

# ==================================================
# Step 16: Display the Summary data frame
# ==================================================
Summary

# ==================================================
# Step 17: Copy Population into a new data frame
#          called Population_v2
# ==================================================
Population_v2 <- Population

# ==================================================
# Step 18: Create a Percent_change variable
# ==================================================
Population_v2 <- Population_v2 %>%
  mutate(Percent_change = Change / EarlierPop)

# ==================================================
# Step 19: Sort Population_v2 by Percent_change
#          in descending order
# ==================================================
Population_v2 <- Population_v2 %>%
  arrange(desc(Percent_change))

# ==================================================
# Step 20: Display the Population_v2 data frame
# ==================================================
Population_v2

# ==================================================
# Step 21: Create a kableExtra-formatted table for
#          Population
# ==================================================
Population_tbl <- Population %>%
  kable(
    caption = "Population Data",
    digits = 3
  ) %>%
  kable_styling(full_width = FALSE)

# ==================================================
# Step 22: Create a kableExtra-formatted table for
#          Change_only
# ==================================================
Change_only_tbl <- Change_only %>%
  kable(
    caption = "County Change Data",
    digits = 3
  ) %>%
  kable_styling(full_width = FALSE)

# ==================================================
# Step 23: Create a kableExtra-formatted table for
#          Doughnut
# ==================================================
Doughnut_tbl <- Doughnut %>%
  kable(
    caption = "Davidson and Doughnut Counties",
    digits = 3
  ) %>%
  kable_styling(full_width = FALSE)

# ==================================================
# Step 24: Create a kableExtra-formatted table for
#          Summary
# ==================================================
Summary_tbl <- Summary %>%
  kable(
    caption = "Regional Population Summary",
    digits = 3
  ) %>%
  kable_styling(full_width = FALSE)

# ==================================================
# Step 25: Create a kableExtra-formatted table for
#          Population_v2
# ==================================================
Population_v2_tbl <- Population_v2 %>%
  kable(
    caption = "Population Data with Percent Change",
    digits = 3
  ) %>%
  kable_styling(full_width = FALSE)

# ==================================================
# Step 26: Display all formatted tables
# ==================================================
Population_tbl
Change_only_tbl
Doughnut_tbl
Summary_tbl
Population_v2_tbl