1 Libraries

library(ggplot2)
library(ggthemes)
library(grid)
library(tidycensus)
library(tidyverse)
library(mapview)
options(tigris_use_cache = TRUE)

2 Getting the Data

NewYork<- get_acs(state = "NY",
                    county = "New York",
                    geography = "tract",
                    variables =  "B06011_004",
                    geometry = TRUE)

3 Creating a map

NewYork %>% 
  ggplot(aes(fill=estimate)) + 
  geom_sf() + 
  labs(title = "Median Income for Foreign-born Residents of New York City ",
       subtitle = "Borough of Manhattan",
       fill="Median Family Income") +
  theme_minimal() +
  theme(axis.text.x = element_text(angle = 45))+
  scale_fill_viridis_c(option = "plasma")

4 Interactive Map

mapview(NewYork, zcol="estimate", legend=TRUE, layer.name="Median Income of Foreign Born Residents")