Project 2: Population Change in the 10 Most Populous States

Author

Supriya P.

Published

October 11, 2026

Introduction

This dataset was posted by Anastasiia Gmyrina in the Week 5 discussion. It comes from the U.S. Census Bureau’s population estimates and covers the 10 most populous states in 2022, with population counts for 2020, 2021, and 2022. My goal is to see how each state’s population changed over those two years.

Raw Data Structure

Code
library(tidyverse)
library(knitr)

raw <- read_csv(
  "https://raw.githubusercontent.com/0pree/symmetrical-robot/refs/heads/main/census_top10_states_2022_untidy.csv",
  show_col_types = FALSE
)

dim(raw)
[1] 10  5
Code
kable(raw)
Rank Geographic Area April 1, 2020 (Estimates Base) July 1, 2021 July 1, 2022
1 California 39538245 39142991 39029342
2 Texas 29145428 29558864 30029572
3 Florida 21538226 21828069 22244823
4 New York 20201230 19857492 19677151
5 Pennsylvania 13002689 13012059 12972008
6 Illinois 12812545 12686469 12582032
7 Ohio 11799374 11764342 11756058
8 Georgia 10711937 10788029 10912876
9 North Carolina 10439414 10565885 10698973
10 Michigan 10077325 10037504 10034113

The table has 10 rows (one per state) and 5 columns. It is wide because each year is a separate column, and the year is buried inside long headers like “April 1, 2020 (Estimates Base)” and “July 1, 2021”. The column names also have spaces and mixed capitalization. There are no missing values.

One detail worth noting is that the 2020 column is an April estimate, while 2021 and 2022 are July estimates. That means the first interval is about 15 months instead of 12, which slightly affects any year to year comparison.

Tidying the Data

Code
population <- raw %>%
  rename(rank_2022 = Rank, state = `Geographic Area`) %>%
  pivot_longer(
    cols = -c(rank_2022, state),
    names_to = "estimate_date",
    values_to = "population"
  ) %>%
  mutate(year = as.integer(str_extract(estimate_date, "\\d{4}"))) %>%
  select(state, rank_2022, year, estimate_date, population)

kable(head(population, 6))
state rank_2022 year estimate_date population
California 1 2020 April 1, 2020 (Estimates Base) 39538245
California 1 2021 July 1, 2021 39142991
California 1 2022 July 1, 2022 39029342
Texas 2 2020 April 1, 2020 (Estimates Base) 29145428
Texas 2 2021 July 1, 2021 29558864
Texas 2 2022 July 1, 2022 30029572

I renamed the columns to lowercase names without spaces, then reshaped the three date columns into rows so each row is one state and one year. To get a usable year, I pulled the four-digit number out of each header with str_extract(). I kept the original estimate_date text in its own column so the April versus July difference is not lost.

Code
nrow(population) == nrow(raw) * 3
[1] TRUE

The tidy table has 30 rows, which matches 10 states times 3 years, so no rows were lost in the reshape.

Analysis

Change from 2020 to 2022

Code
change <- population %>%
  select(state, year, population) %>%
  pivot_wider(names_from = year, values_from = population, names_prefix = "pop_") %>%
  mutate(
    change = pop_2022 - pop_2020,
    pct_change = round(change / pop_2020 * 100, 2)
  ) %>%
  arrange(desc(pct_change))

kable(
  change,
  format.args = list(big.mark = ","),
  col.names = c("State", "2020", "2021", "2022", "Change", "Percent Change (%)")
)
State 2020 2021 2022 Change Percent Change (%)
Florida 21,538,226 21,828,069 22,244,823 706,597 3.28
Texas 29,145,428 29,558,864 30,029,572 884,144 3.03
North Carolina 10,439,414 10,565,885 10,698,973 259,559 2.49
Georgia 10,711,937 10,788,029 10,912,876 200,939 1.88
Pennsylvania 13,002,689 13,012,059 12,972,008 -30,681 -0.24
Ohio 11,799,374 11,764,342 11,756,058 -43,316 -0.37
Michigan 10,077,325 10,037,504 10,034,113 -43,212 -0.43
California 39,538,245 39,142,991 39,029,342 -508,903 -1.29
Illinois 12,812,545 12,686,469 12,582,032 -230,513 -1.80
New York 20,201,230 19,857,492 19,677,151 -524,079 -2.59
Code
ggplot(change, aes(x = reorder(state, pct_change), y = pct_change, fill = pct_change > 0)) +
  geom_col() +
  coord_flip() +
  scale_fill_manual(values = c("TRUE" = "steelblue", "FALSE" = "firebrick"), guide = "none") +
  labs(
    title = "Population Change from 2020 to 2022",
    x = NULL, y = "Percent Change (%)"
  ) +
  theme_minimal()

Six of the ten states lost population and four gained. Florida grew the most by percentage (3.28%), followed closely by Texas (3.03%), and Texas added the most people overall, about 884,000. New York lost the most by percentage (2.59%) and also the most people, about 524,000. California lost almost as many people (about 509,000), but because its population is so large, that was only a 1.29% drop.

Growth Pattern by Region

Code
change %>%
  mutate(region = if_else(state %in% c("Texas", "Florida", "Georgia", "North Carolina"), "South", "Other")) %>%
  group_by(region) %>%
  summarize(
    states = n(),
    total_change = sum(change),
    .groups = "drop"
  ) %>%
  kable(format.args = list(big.mark = ","), col.names = c("Region", "States", "Total Change"))
Region States Total Change
Other 6 -1,380,704
South 4 2,051,239

All four states that grew are in the South. Together they gained about 2.05 million people, while the other six states lost about 1.38 million. Across all ten states, the total population only grew by about 0.37%, so most of the movement was people shifting between states rather than overall growth.

Year by Year

Code
ggplot(population, aes(x = year, y = population / 1e6, color = state)) +
  geom_line() +
  geom_point() +
  scale_x_continuous(breaks = c(2020, 2021, 2022)) +
  labs(
    title = "Population Estimates by State",
    x = "Year", y = "Population (millions)", color = "State"
  ) +
  theme_minimal()

Because California and Texas are so much larger than the other states, this chart makes the changes in the smaller states hard to see, which is why the percent change chart above is more useful for comparing them.

Conclusions

This was the simplest of the three datasets to tidy. The main step was pulling the year out of long column headers and reshaping the year columns into rows. The analysis shows a clear pattern: between 2020 and 2022, the large Southern states gained population while New York, Illinois, and California lost it. Since the 2020 estimate is from April and the others are from July, the first interval is a little longer, so these numbers slightly overstate change compared to a true two year window.

A next step would be to add more recent Census estimates to see whether this shift continued after 2022, or to include all 50 states and look at domestic migration specifically.

AI Citation

Anthropic. (2026). Claude Opus 5.5 [Large language model]. https://claude.ai. Accessed October 2026.