Mini-project for SDS 264 - Data Science 2 where 4 informative maps were created, 2 choropleth and 2 interactive
Author
Ziling Zhen
Published
September 20, 2024
This project uses R to create static and interactive maps visualizing US state-level data on population change from 2010 to 2020 and marijuana laws in 2022. Using libraries like tidyverse, maps, leaflet, and sf. Interactive maps allow users to explore state-level differences dynamically, adding a layer of accessibility and engagement.
Percentage Change in Population of the US from 2010 to 2020
Code
# First static plotggplot(census_sf) +geom_sf(aes(fill = perc_change)) +scale_fill_gradient2(high ="#2aab32", mid ="white",low ="red",limits =c(-15, 20)) +labs(title ="Percentage Change in Population of the US from 2010 to 2020",fill ="% Change",caption =" Source: data.census.gov") +theme_bw()
This is a map of the United States showing the percent change in population of the United States from 2010 to 2020 by state. On the y-axis is longitude and on the x-axis is latitude. Percent change varies from a decrease of -3% of the population to an increase of 18%, with red representing a decrease in population (a negative percentage) and green representing an increase in population (a positive percentage). We can see from this map that Utah, Idaho, and Texas had the largest percent increase in population. The states in the Midwest, such as Illinois, Iowa, Minnesota, South Dakota, Wisconsin, etc. (the 90W and 45N area), the states also had an increase in population however it is a smaller percentage. West Virginia is the only visible state that is red and this represents a decrease in population by 3.19%. For the population increase in states, this could be caused by people moving states, and more people in the United States overall.
Same Map, but Interactive!
Legalization of Marijuana in the US 2022
Code
# Second static plotggplot(marijuana_laws2024_sf) +geom_sf(aes(fill = LegalStatus)) +scale_fill_manual(values =c("#e41a1c", "#4daf4a", "#377eb8")) +labs(title ="Legalization of Marijuana in the US 2022",fill ="Legaility",caption ="Source: https://worldpopulationreview.com/state-rankings/marijuana-laws-by-state") +theme_bw()
This is a map of the United States showing the legalization of marijuana in 2022. On the y-axis is longitude and on the x-axis is latitude. The categories of legality are “Illegal”, “Legalized”, and “Mixed”, with the associated colors on the map being red, green, and blue, respectively. There are 6 states where marijuana is illegal, these states are Idaho, Kansas, Nebraska, North and South Carolina, and Wyoming. On the map, 2 of these states are on the East Coast and the rest are in the middle of the US. For the rest of the US, marijuana is either legalized or has mixed laws. A lot of the states in the west have legalized marijuana, this includes Oregon, Washington, California, along with Nevada and Arizona. There are also some states on the East Coast have also legalized marijuana. Where as states in the south and in the Midwest have mixed laws. Note that this is data from 2022, and some states with mixed laws, are now fully legalized.