Created
December 21, 2024 22:20
-
-
Save walkerke/b4f97180b839d85b87b5872fff01e490 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidycensus) | |
library(ggplot2) | |
library(dplyr) | |
state_mig <- get_estimates( | |
geography = "state", | |
variables = c("RDOMESTICMIG", "RINTERNATIONALMIG"), | |
vintage = 2024, | |
output = "wide" | |
) | |
ggplot(state_mig, aes(y = reorder(NAME, RDOMESTICMIG))) + | |
geom_segment(aes(x = RDOMESTICMIG, xend = RINTERNATIONALMIG, yend = NAME), | |
color = "#959595", size = 1.5) + | |
geom_point(aes(x = RDOMESTICMIG), color = "red", size = 3) + | |
geom_point(aes(x = RINTERNATIONALMIG), color = "blue", size = 3) + | |
geom_vline(xintercept = 0, color = "black", size = 1) + | |
theme_minimal() + | |
theme( | |
panel.grid.minor.y = element_blank(), | |
axis.text.y = element_text(size = 8) | |
) + | |
labs( | |
title = "Comparison of International vs. Domestic Migration Rates by State", | |
subtitle = "Red: Domestic Migration Rate | Blue: International Migration Rate", | |
x = "Migration Rate (per 1000 people)", | |
y = "State" | |
) + | |
scale_x_continuous(breaks = c(-5, 0, 15)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment