The population data presented in this table comes from the U.S. Census Bureau’s American Community Survey (ACS).
The table shows population change among Nashville-area counties, ranked from highest to lowest by percent change. Williamson County experienced the highest rate of population growth at approximately 25.0%, followed by Rutherford County at 23.3%, Wilson County at 22.2%, and Maury County at 21.5%. Although Davidson County added the largest number of residents overall, with an increase of 117,204 people, it ranked fifth in percent population change at approximately 19.6%. This suggests that population growth in the Nashville area extends beyond Davidson County, with several surrounding counties growing at faster rates relative to their earlier populations.
| 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 |
# 1. Install required packages if needed 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)
# 2. Create the county name vector --------------------------------------------
County <- c("Cannon", "Cheatham", "Davidson", "Dickson", "Hickman", "Macon",
"Maury", "Robertson", "Rutherford", "Smith", "Sumner", "Trousdale",
"Williamson", "Wilson")
# 3. Create the current population vector -------------------------------------
CurrentPop <- c(14818, 41829, 715388, 55983, 25436, 26240, 107791, 75539,
360646, 20389, 204424, 11957, 260351, 158805)
# 4. Create the earlier population vector -------------------------------------
EarlierPop <- c(13958, 39087, 598184, 51608, 24561, 23261, 88738, 67517,
292425, 19389, 174773, 10131, 208242, 129918)
# 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")
# 6. Combine the vectors into the Population data frame -----------------------
Population <- data.frame(
County,
CurrentPop,
EarlierPop,
Region
)
# 7. Sort Population by current population and display it ---------------------
Population <- Population %>%
arrange(desc(CurrentPop))
Population
# 8. Add a Change variable and display the updated data frame -----------------
Population <- Population %>%
mutate(Change = CurrentPop - EarlierPop)
Population
# 9. Create Change_only and sort it by population change ----------------------
Change_only <- Population %>%
select(County, Change) %>%
arrange(desc(Change))
Change_only
# 10. Create Doughnut with Davidson and Doughnut counties only ----------------
Doughnut <- Population %>%
filter(Region == "Davidson" | Region == "Doughnut") %>%
arrange(desc(Change))
Doughnut
# 11. Summarize population totals by region -----------------------------------
Summary <- Population %>%
group_by(Region) %>%
summarize(
CurrentPop = sum(CurrentPop),
EarlierPop = sum(EarlierPop),
Change = sum(Change)
)
Summary
# 12. Copy Population into a new Population_v2 data frame ---------------------
Population_v2 <- Population
# 13. Calculate percent change and sort from highest to lowest ----------------
Population_v2 <- Population_v2 %>%
mutate(Percent_change = Change / EarlierPop) %>%
arrange(desc(Percent_change))
Population_v2
# 14. Create kableExtra-formatted tables --------------------------------------
Population_table <- Population %>%
kbl(
caption = "Nashville-Area County Population",
digits = 3
) %>%
kable_styling(
bootstrap_options = c("striped", "hover", "condensed"),
full_width = FALSE
)
Change_only_table <- Change_only %>%
kbl(
caption = "Population Change by County",
digits = 3
) %>%
kable_styling(
bootstrap_options = c("striped", "hover", "condensed"),
full_width = FALSE
)
Doughnut_table <- Doughnut %>%
kbl(
caption = "Population Change in Davidson and Doughnut Counties",
digits = 3
) %>%
kable_styling(
bootstrap_options = c("striped", "hover", "condensed"),
full_width = FALSE
)
Summary_table <- Summary %>%
kbl(
caption = "Population Summary by Region",
digits = 3
) %>%
kable_styling(
bootstrap_options = c("striped", "hover", "condensed"),
full_width = FALSE
)
Population_v2_table <- Population_v2 %>%
kbl(
caption = "Population Change in Nashville-Area Counties",
digits = 3
) %>%
kable_styling(
bootstrap_options = c("striped", "hover", "condensed"),
full_width = FALSE
)
# 15. Display the kableExtra-formatted tables ---------------------------------
Population_table
Change_only_table
Doughnut_table
Summary_table
Population_v2_table