Project 2 — Dataset 3: US State Population Change, 2020–2024

Author

Yalda Azamee

Published

November 28, 2026

Introduction

The U.S. Census Bureau publishes yearly population estimates for every state, together with the components of change: births, deaths, international migration, and domestic migration (people moving between states) (Census Bureau: State Population Totals and Components of Change, 2020–2024). The file is very wide: each measure is repeated for every year in its own column, such as POPESTIMATE2020 … POPESTIMATE2024 and BIRTHS2020 … BIRTHS2024. Analysis question: Which states grew fastest from 2020 to 2024, and did the growth come from natural change (births minus deaths) or from migration?

Data Source

I downloaded the “Annual Estimates of the Resident Population and Components of Change” dataset (NST-EST2024-ALLDATA.csv) and saved it without changes as data/census_state_population_raw.csv in my GitHub repository. The code below reads it from GitHub, so it runs on any computer.

library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.2.1     ✔ readr     2.2.0
✔ forcats   1.0.1     ✔ stringr   1.6.0
✔ ggplot2   4.0.3     ✔ tibble    3.3.1
✔ lubridate 1.9.5     ✔ tidyr     1.3.2
✔ purrr     1.2.2     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
theme_set(theme_minimal(base_size = 12))  # same chart style in all three datasets

raw_url <- "https://raw.githubusercontent.com/YaldaAzamee/data607-project2/main/data/census_state_population_raw.csv"
raw     <- read.csv(raw_url)

Data Structure Before Tidying

The raw data has 66 rows and 75 columns. The column names are:

names(raw)
 [1] "SUMLEV"                "REGION"                "DIVISION"             
 [4] "STATE"                 "NAME"                  "ESTIMATESBASE2020"    
 [7] "POPESTIMATE2020"       "POPESTIMATE2021"       "POPESTIMATE2022"      
[10] "POPESTIMATE2023"       "POPESTIMATE2024"       "NPOPCHG_2020"         
[13] "NPOPCHG_2021"          "NPOPCHG_2022"          "NPOPCHG_2023"         
[16] "NPOPCHG_2024"          "BIRTHS2020"            "BIRTHS2021"           
[19] "BIRTHS2022"            "BIRTHS2023"            "BIRTHS2024"           
[22] "DEATHS2020"            "DEATHS2021"            "DEATHS2022"           
[25] "DEATHS2023"            "DEATHS2024"            "NATURALCHG2020"       
[28] "NATURALCHG2021"        "NATURALCHG2022"        "NATURALCHG2023"       
[31] "NATURALCHG2024"        "INTERNATIONALMIG2020"  "INTERNATIONALMIG2021" 
[34] "INTERNATIONALMIG2022"  "INTERNATIONALMIG2023"  "INTERNATIONALMIG2024" 
[37] "DOMESTICMIG2020"       "DOMESTICMIG2021"       "DOMESTICMIG2022"      
[40] "DOMESTICMIG2023"       "DOMESTICMIG2024"       "NETMIG2020"           
[43] "NETMIG2021"            "NETMIG2022"            "NETMIG2023"           
[46] "NETMIG2024"            "RESIDUAL2020"          "RESIDUAL2021"         
[49] "RESIDUAL2022"          "RESIDUAL2023"          "RESIDUAL2024"         
[52] "RBIRTH2021"            "RBIRTH2022"            "RBIRTH2023"           
[55] "RBIRTH2024"            "RDEATH2021"            "RDEATH2022"           
[58] "RDEATH2023"            "RDEATH2024"            "RNATURALCHG2021"      
[61] "RNATURALCHG2022"       "RNATURALCHG2023"       "RNATURALCHG2024"      
[64] "RINTERNATIONALMIG2021" "RINTERNATIONALMIG2022" "RINTERNATIONALMIG2023"
[67] "RINTERNATIONALMIG2024" "RDOMESTICMIG2021"      "RDOMESTICMIG2022"     
[70] "RDOMESTICMIG2023"      "RDOMESTICMIG2024"      "RNETMIG2021"          
[73] "RNETMIG2022"           "RNETMIG2023"           "RNETMIG2024"          

A sample of the raw data (first 5 rows and first 9 columns):

raw[1:5, 1:9] |> knitr::kable(format.args = list(big.mark = ","))
SUMLEV REGION DIVISION STATE NAME ESTIMATESBASE2020 POPESTIMATE2020 POPESTIMATE2021 POPESTIMATE2022
10 0 0 0 United States 331,515,736 331,577,720 332,099,760 334,017,321
20 1 0 0 Northeast Region 57,617,706 57,431,458 57,252,533 57,159,597
30 1 1 0 New England 15,122,011 15,057,350 15,118,145 15,175,633
30 1 2 0 Middle Atlantic 42,495,695 42,374,108 42,134,388 41,983,964
20 2 0 0 Midwest Region 68,998,970 68,984,258 68,872,831 68,903,297

Notes about the raw structure:

  • Except for the first five ID columns, every column name joins a measure and a year (for example BIRTHS2021, NPOPCHG_2022). This is why the table is wide.
  • The rows mix different geographic levels, identified by SUMLEV: 10, 20, 30, 40 (010 = United States, 020 = region, 030 = division, 040 = state).
  • Column names are uppercase codes, such as NATURALCHG (natural change) and RBIRTH (birth rate).

Transformation Steps

Step 1: Reshape from wide to long

I stack all the measure-year columns into rows with pivot_longer(). names_pattern splits each column name into the measure (letters) and the year (last four digits). The optional _ handles names like NPOPCHG_2020.

long <- raw |>
  pivot_longer(
    cols          = matches("\\d{4}$"),
    names_to      = c("measure", "year"),
    names_pattern = "^(.*?)_?(\\d{4})$",
    values_to     = "value"
  )

head(long)
# A tibble: 6 × 8
  SUMLEV REGION DIVISION STATE NAME          measure       year      value
   <int> <chr>  <chr>    <int> <chr>         <chr>         <chr>     <dbl>
1     10 0      0            0 United States ESTIMATESBASE 2020  331515736
2     10 0      0            0 United States POPESTIMATE   2020  331577720
3     10 0      0            0 United States POPESTIMATE   2021  332099760
4     10 0      0            0 United States POPESTIMATE   2022  334017321
5     10 0      0            0 United States POPESTIMATE   2023  336806231
6     10 0      0            0 United States POPESTIMATE   2024  340110988
unique(long$measure)
 [1] "ESTIMATESBASE"     "POPESTIMATE"       "NPOPCHG"          
 [4] "BIRTHS"            "DEATHS"            "NATURALCHG"       
 [7] "INTERNATIONALMIG"  "DOMESTICMIG"       "NETMIG"           
[10] "RESIDUAL"          "RBIRTH"            "RDEATH"           
[13] "RNATURALCHG"       "RINTERNATIONALMIG" "RDOMESTICMIG"     
[16] "RNETMIG"          

Step 2: Normalize the variable structure

The value column now mixes very different measures: people, births, and rates. In tidy data each measure should be its own variable, so I use pivot_wider() to give every measure its own column. Each row is then one geographic area in one year. I also convert year to an integer and replace the SUMLEV and REGION codes with readable labels.

normalized <- long |>
  pivot_wider(names_from = measure, values_from = value) |>
  mutate(
    year      = as.integer(year),
    geo_level = case_when(
      SUMLEV == 10 ~ "Nation",
      SUMLEV == 20 ~ "Region",
      SUMLEV == 30 ~ "Division",
      SUMLEV == 40 ~ "State"
    ),
    REGION = recode(REGION, "1" = "Northeast", "2" = "Midwest", "3" = "South", "4" = "West")
  )

dim(normalized)
[1] 330  23

Step 3: Rename variables

I rename all columns to lowercase snake_case and replace the Census codes with descriptive names.

renamed <- normalized |>
  rename_with(tolower) |>
  rename(
    area                   = name,
    population_base        = estimatesbase,
    population             = popestimate,
    pop_change             = npopchg,
    natural_change         = naturalchg,
    international_mig      = internationalmig,
    domestic_mig           = domesticmig,
    net_mig                = netmig,
    birth_rate             = rbirth,
    death_rate             = rdeath,
    natural_change_rate    = rnaturalchg,
    international_mig_rate = rinternationalmig,
    domestic_mig_rate      = rdomesticmig,
    net_mig_rate           = rnetmig
  ) |>
  select(-sumlev, -division, -state)  # codes no longer needed

names(renamed)
 [1] "region"                 "area"                   "year"                  
 [4] "population_base"        "population"             "pop_change"            
 [7] "births"                 "deaths"                 "natural_change"        
[10] "international_mig"      "domestic_mig"           "net_mig"               
[13] "residual"               "birth_rate"             "death_rate"            
[16] "natural_change_rate"    "international_mig_rate" "domestic_mig_rate"     
[19] "net_mig_rate"           "geo_level"             

Step 4: Handle missing and inconsistent values

# Missing values in each column, by year
renamed |>
  group_by(year) |>
  summarise(across(everything(), ~ sum(is.na(.x)))) |>
  select(year, where(~ is.numeric(.x) && sum(.x) > 0)) |>
  knitr::kable()
year population_base birth_rate death_rate natural_change_rate international_mig_rate domestic_mig_rate net_mig_rate
2020 0 66 66 66 66 66 66
2021 66 0 0 0 0 0 0
2022 66 0 0 0 0 0 0
2023 66 0 0 0 0 0 0
2024 66 0 0 0 0 0 0
# Puerto Rico: region code and domestic migration
renamed |> filter(area == "Puerto Rico") |> select(area, region, year, domestic_mig) |> knitr::kable()
area region year domestic_mig
Puerto Rico X 2020 0
Puerto Rico X 2021 0
Puerto Rico X 2022 0
Puerto Rico X 2023 0
Puerto Rico X 2024 0

Decisions:

  • Missing rates in 2020: the rate columns (birth_rate, …) do not exist for 2020 in the raw file, so they are NA after reshaping. The 2020 estimates only cover April 1 to July 1, 2020 (about three months), so rates are not published. I keep the NA values because they are correct, and my analysis does not use rates for 2020.
  • Missing population_base in 2021–2024: the base population (the April 1, 2020 starting point) exists only for 2020, so it is NA in the other years. This is also correct, and I do not use it in the analysis.
  • Partial year 2020: for the same reason, the 2020 components (births, deaths, migration) cover only three months. To compare full years, I add up the components for 2021–2024 only (each covers July 1 to June 30). I measure growth from the July 1, 2020 estimate to the July 1, 2024 estimate, so both use the same time period.
  • Mixed geographic levels: the nation, regions, and divisions are sums of states. I keep only states (geo_level == "State") so nothing is counted twice.
  • Puerto Rico: its region is "X" (not part of any region) and its domestic migration is always 0, because moving between Puerto Rico and the states is counted differently. I remove it, so the analysis covers the 50 states and the District of Columbia.
states_tidy <- renamed |>
  filter(geo_level == "State", area != "Puerto Rico") |>
  select(-geo_level)

n_distinct(states_tidy$area)
[1] 51
head(states_tidy)
# A tibble: 6 × 19
  region area     year population_base population pop_change births deaths
  <chr>  <chr>   <int>           <dbl>      <dbl>      <dbl>  <dbl>  <dbl>
1 South  Alabama  2020         5025369    5033094       7725  13867  15146
2 South  Alabama  2021              NA    5049196      16102  57184  69134
3 South  Alabama  2022              NA    5076181      26985  58103  67246
4 South  Alabama  2023              NA    5117673      41492  58528  60059
5 South  Alabama  2024              NA    5157699      40026  57541  59273
6 West   Alaska   2020          733395     733017       -378   2406   1169
# ℹ 11 more variables: natural_change <dbl>, international_mig <dbl>,
#   domestic_mig <dbl>, net_mig <dbl>, residual <dbl>, birth_rate <dbl>,
#   death_rate <dbl>, natural_change_rate <dbl>, international_mig_rate <dbl>,
#   domestic_mig_rate <dbl>, net_mig_rate <dbl>

The final tidy dataset has 255 rows (51 states × 5 years) and 19 columns.

Analytical Methods

All analysis uses the tidy dataset states_tidy. For each state I calculate:

  • Growth (%) = (population on July 1, 2024 − population on July 1, 2020) ÷ population in 2020 × 100.
  • Components of growth, 2021–2024: the sum of natural change, international migration, and domestic migration, each shown as a percentage of the 2020 population. This makes large and small states comparable and shows where the growth came from.

I then compare the fastest- and slowest-growing states, and summarize the components for the ten fastest-growing states in a stacked bar chart.

Analysis

growth <- states_tidy |>
  group_by(area, region) |>
  summarise(
    pop_2020          = population[year == 2020],
    pop_2024          = population[year == 2024],
    natural_change    = sum(natural_change[year >= 2021]),
    international_mig = sum(international_mig[year >= 2021]),
    domestic_mig      = sum(domestic_mig[year >= 2021]),
    .groups = "drop"
  ) |>
  mutate(
    growth_pct            = round(100 * (pop_2024 - pop_2020) / pop_2020, 1),
    natural_pct           = round(100 * natural_change / pop_2020, 1),
    international_mig_pct = round(100 * international_mig / pop_2020, 1),
    domestic_mig_pct      = round(100 * domestic_mig / pop_2020, 1)
  ) |>
  arrange(desc(growth_pct))

label_table <- function(d) {
  d |>
    select(
      State                                 = area,
      Region                                = region,
      `Population 2020 (people)`            = pop_2020,
      `Population 2024 (people)`            = pop_2024,
      `Growth (%)`                          = growth_pct,
      `Natural change (% of 2020 pop.)`     = natural_pct,
      `International migration (% of 2020)` = international_mig_pct,
      `Domestic migration (% of 2020)`      = domestic_mig_pct
    ) |>
    knitr::kable(format.args = list(big.mark = ","))
}

growth |> slice_head(n = 10) |> label_table()
State Region Population 2020 (people) Population 2024 (people) Growth (%) Natural change (% of 2020 pop.) International migration (% of 2020) Domestic migration (% of 2020)
Florida South 21,592,035 23,372,215 8.2 -0.4 4.9 3.8
Idaho West 1,849,415 2,001,619 8.2 1.1 1.2 6.0
Texas South 29,239,570 31,290,831 7.0 1.8 2.8 2.4
South Carolina South 5,132,249 5,478,831 6.8 -0.3 1.2 5.8
Utah West 3,284,077 3,503,613 6.7 2.9 2.4 1.4
Delaware South 991,928 1,051,917 6.0 -0.2 1.8 4.4
North Carolina South 10,449,652 11,046,024 5.7 0.3 1.7 3.7
Arizona West 7,187,135 7,582,384 5.5 0.2 2.2 3.1
Nevada West 3,116,967 3,267,467 4.8 0.2 2.3 2.3
District of Columbia South 670,917 702,250 4.7 1.7 5.2 -2.1

The five states with the lowest growth:

growth |> slice_tail(n = 5) |> label_table()
State Region Population 2020 (people) Population 2024 (people) Growth (%) Natural change (% of 2020 pop.) International migration (% of 2020) Domestic migration (% of 2020)
Mississippi South 2,958,536 2,943,045 -0.5 -0.5 0.7 -0.7
Illinois Midwest 12,799,088 12,710,158 -0.7 0.2 2.2 -3.1
Louisiana South 4,652,301 4,597,740 -1.2 0.2 1.3 -2.7
New York Northeast 20,105,171 19,867,248 -1.2 0.7 2.6 -4.4
West Virginia South 1,791,646 1,769,979 -1.2 -2.2 0.4 0.6
top10 <- growth |> slice_head(n = 10)

top10 |>
  select(area, natural_pct, international_mig_pct, domestic_mig_pct) |>
  pivot_longer(-area, names_to = "component", values_to = "pct") |>
  mutate(
    component = recode(component,
                       natural_pct           = "Natural change (births − deaths)",
                       international_mig_pct = "International migration",
                       domestic_mig_pct      = "Domestic migration"),
    area = factor(area, levels = rev(top10$area))
  ) |>
  ggplot(aes(pct, area, fill = component)) +
  geom_col() +
  geom_vline(xintercept = 0, color = "grey40") +
  scale_fill_manual(values = c(
    "Natural change (births − deaths)" = "#009E73",
    "International migration"          = "#0072B2",
    "Domestic migration"               = "#D55E00"
  )) +
  labs(
    title    = "Where Growth Came From in the 10 Fastest-Growing States",
    subtitle = "Components of population change, July 2020 to July 2024",
    x        = "Change as % of 2020 population",
    y        = NULL,
    fill     = "Component"
  ) +
  theme(legend.position = "bottom")

Conclusions

Findings

  • Florida grew the fastest: its population rose by 8.2%, from 21,592,035 to 23,372,215.
  • West Virginia had the lowest growth (-1.2%). In total, 7 states lost population between 2020 and 2024.
  • Migration drove the fastest growth, not births. In 8 of the 10 fastest-growing states, domestic migration (people moving from other states) added more people than natural change.
  • The South dominates: 6 of the 10 fastest-growing states are in the South region.
  • Natural change is small or negative in many states: in 22 states, deaths outnumbered births from 2021 to 2024, so those states could only grow through migration.

AI Use

Anthropic. (2026). Claude Opus 5.5 [Large language model]. https://claude.ai. Accessed November 28, 2026. Used to help select the dataset,and understand the assignment requirements.