I'm trying to use the tigris package in R to make a map of Douglas County, Colorado. The goal is to show Douglas County divided by the zip codes inside of it, and to have each zip code shaded based on a value. The variables I have right now in my dataset are: Zip code, town, and lead level (continuous variable).
library(tigris)
library(sf)
douglas_zips <- zctas(cb=TRUE, starts_with= c("80108","80109", "80104", "80116", "80126", "80129", "80130", "80118", "80124", "80131", "80134", "80138", "80125", "80135"))
plot(douglas_zips)
When I do this, I get this strange plot: zip code map
Any thoughts or ideas of where to go from here?
That's showing a map of those zip areas for every column in the data frame. Each row of the data frame is a zip area, and each row has a few columns of info with it. By default, plotting such an object does a map for each column (up to a smallish limit). If you print the object out you'll see its data-frame nature:
To plot just one column, do
plot(douglas_zips["ZCTA5CE20"]):