# NOT RUN {
library(tidycensus)
library(tidyverse)
library(viridis)
census_api_key("YOUR KEY GOES HERE")
tarr <- get_acs(geography = "tract", variables = "B19013_001",
state = "TX", county = "Tarrant", geometry = TRUE, year = 2020)
ggplot(tarr, aes(fill = estimate, color = estimate)) +
geom_sf() +
coord_sf(crs = 26914) +
scale_fill_viridis(option = "magma") +
scale_color_viridis(option = "magma")
vt <- get_acs(geography = "county", variables = "B19013_001", state = "VT", year = 2019)
vt %>%
mutate(NAME = gsub(" County, Vermont", "", NAME)) %>%
ggplot(aes(x = estimate, y = reorder(NAME, estimate))) +
geom_errorbar(aes(xmin = estimate - moe, xmax = estimate + moe), width = 0.3, size = 0.5) +
geom_point(color = "red", size = 3) +
labs(title = "Household income by county in Vermont",
subtitle = "2015-2019 American Community Survey",
y = "",
x = "ACS estimate (bars represent margin of error)")
# }
Run the code above in your browser using DataLab