Code
library(tidyverse)
library(tidycensus)
library(sf)
library(ggthemes)
library(viridis)
# In .Renviron
# CENSUS_API_KEY="your census"
census_api_key(Sys.getenv("CENSUS_API_KEY"), install = TRUE, overwrite = TRUE)
#> [1] ""
author
argument and put today’s date in the date
argument.5-lab5.html
page.theme
argument in the header to something else - you can see other available themes here. Notice the difference when you render now!tidycensus
and ggplot2
In this lab, you will recreate a public map visualization of plumbing access across the U.S. using data from the American Community Survey (ACS) via the tidycensus
package. You will:
get_acs()
to retrieve county-level dataggplot2
library(tidyverse)
library(tidycensus)
library(sf)
library(ggthemes)
library(viridis)
# In .Renviron
# CENSUS_API_KEY="your census"
census_api_key(Sys.getenv("CENSUS_API_KEY"), install = TRUE, overwrite = TRUE)
#> [1] ""
Use get_acs() to retrieve county-level data for the Western states in 2022 and 2023:
Total population: B01003_001
Households without plumbing: B25016_003
# your code here, or use the code from tutorial
Pivot the data wider so that each row contains both population and plumbing information. Check your result using glimpse()
or summary()
.
# your code here, or use the code from tutorial
In this tutorial, they use geom_sf()
to make choropleth map, but you can also use tmap()
like we covered in the lecture if you prefer.
# your code here, or use the code from tutorial
What does this preview map show? Are there clear spatial patterns?
Type your response here.
Recreate the polished map from the USGS tutorial. Consider:
# your code here, or use the code from tutorial
What refinements did you add in step 5 compared to step 4? How do these changes improve the visualization?
Type your response here.
Use the same dataset and design a different map. Possibilities include:
# your code here
explain what your new visualization shows.
Remember to save your .qmd
and render the HTML output before committing to GitHub.
git add 5-lab5.qmd 5-lab5.html
git commit -m "Final submission for Lab5"
git push