Tennessee Midstate Population Analysis

The fastest growing counties in the Tennessee “midstate” area are Williamson and Rutherford counties, based on the percentage change in population measured over a five-year period using data obtained by the U.S. Census Bureau’s American Community Survey. The population table below ranks counties in Middle Tennessee in the Nashville Metropolitan Statistical Area. While Davidson County, home of the city of Nashville, is the most populated in the midstate, it ranks fifth for percentage change in population behind Williamson, Rutherford, Wilson, and Maury counties.

The table below shows the growth change of each county, ranked in descending order.

County Population Percentage Change
County Current Population Earlier Population Region Change Percent Change
Williamson 260,351 208,242 Doughnut 52,109 0.2502
Rutherford 360,646 292,425 Doughnut 68,221 0.2333
Wilson 158,805 129,918 Doughnut 28,887 0.2223
Maury 107,791 88,738 Non-doughnut 19,053 0.2147
Davidson 715,388 598,184 Davidson 117,204 0.1959
Trousdale 11,957 10,131 Non-doughnut 1,826 0.1802
Sumner 204,424 174,773 Doughnut 29,651 0.1697
Macon 26,240 23,261 Non-doughnut 2,979 0.1281
Robertson 75,539 67,517 Doughnut 8,022 0.1188
Dickson 55,983 51,608 Non-doughnut 4,375 0.0848
Cheatham 41,829 39,087 Doughnut 2,742 0.0702
Cannon 14,818 13,958 Non-doughnut 860 0.0616
Smith 20,389 19,389 Non-doughnut 1,000 0.0516
Hickman 25,436 24,561 Non-doughnut 875 0.0356

Code:

Below is the code used in R studio to produce the population table using data obtained from the U.S. Census Bureau’s American Community Survey.

# =============================================================================
# Step 1: Install required packages if necessary and load them
# =============================================================================

if (!requireNamespace("tidyverse", quietly = TRUE)) {
  install.packages("tidyverse")
}

if (!requireNamespace("knitr", quietly = TRUE)) {
  install.packages("knitr")
}

if (!requireNamespace("kableExtra", quietly = TRUE)) {
  install.packages("kableExtra")
}

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: Assign each county to a region
# =============================================================================

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 the vectors into a Population data frame
# =============================================================================

Population <- data.frame(
  County,
  CurrentPop,
  EarlierPop,
  Region
)


# =============================================================================
# Step 7: Add the population change for each county
# =============================================================================

Population <- dplyr::mutate(
  Population,
  Change = CurrentPop - EarlierPop
)


# =============================================================================
# Step 8: Sort counties by current population from greatest to smallest
# =============================================================================

Population <- dplyr::arrange(
  Population,
  dplyr::desc(CurrentPop)
)


# =============================================================================
# Step 9: Display the updated and sorted Population data frame
# =============================================================================

print(Population)


# =============================================================================
# Step 10: Copy Population into a new data frame called Population_v2
# =============================================================================

Population_v2 <- Population


# =============================================================================
# Step 11: Calculate each county's percentage population change
# =============================================================================

Population_v2 <- dplyr::mutate(
  Population_v2,
  Percent_change = Change / EarlierPop
)


# =============================================================================
# Step 12: Sort Population_v2 by Percent_change in descending order
# =============================================================================

Population_v2 <- dplyr::arrange(
  Population_v2,
  dplyr::desc(Percent_change)
)


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

print(Population_v2)


# =============================================================================
# Step 14: Create a formatted table for the Population data frame
# =============================================================================

Population_table <- knitr::kable(
  Population,
  format = "html",
  caption = "County Population Data",
  col.names = c(
    "County",
    "Current Population",
    "Earlier Population",
    "Region",
    "Change"
  ),
  format.args = list(
    big.mark = ","
  )
) %>%
  kableExtra::kable_styling(
    bootstrap_options = c("striped", "hover", "condensed"),
    full_width = FALSE,
    position = "center"
  )


# =============================================================================
# Step 15: Display the formatted Population table
# =============================================================================

Population_table


# =============================================================================
# Step 16: Create a formatted table for the Population_v2 data frame
# =============================================================================

Population_v2_table <- knitr::kable(
  Population_v2,
  format = "html",
  caption = "County Population Percentage Change",
  digits = c(0, 0, 0, 0, 0, 4),
  col.names = c(
    "County",
    "Current Population",
    "Earlier Population",
    "Region",
    "Change",
    "Percent Change"
  ),
  format.args = list(
    big.mark = ","
  )
) %>%
  kableExtra::kable_styling(
    bootstrap_options = c("striped", "hover", "condensed"),
    full_width = FALSE,
    position = "center"
  )


# =============================================================================
# Step 17: Display the formatted Population_v2 table
# =============================================================================

Population_v2_table