This project maps the distribution and density of people self-reported racial identity in New York City, using 2020 American Community Survey data.
library(tidyverse)
library(tidycensus)
library(sf)
library(scales)
library(viridis)
library(plotly)
library(knitr)
The borough boundaries are represented with a shape file downloaded from NYC Open Data.
The census tract boundaries and data come from the 2016-2020 5-year American Community Survey, accessed with the tidyverse R package.
Census data includes:
A calculated percentage of people reporting as Hispanic, White-alone, Asian-alone, and Black-alone in each census tract (census tracts with no residents were removed).
boros <- st_read("~/Desktop/GRAD SCHOO/Year 1/Semester 1/Methods/part2/data/raw/geo/Borough_Boundaries.geojson")
nabes <- st_read("~/Desktop/GRAD SCHOO/Year 1/Semester 1/Methods/part2/data/raw/geo/nynta2020_24c/nynta2020.shp")
nyc_counties <- c("Bronx", "Kings", "New York", "Queens", "Richmond")
raw_race <- get_acs(geography = "tract",
variables = c(total_pop = "B01003_001",
hispanic = "B03002_012",
white_alone = "B03002_003",
black_alone = "B03002_004",
asian_alone = "B03002_006"),
state = "NY",
county = nyc_counties,
geometry = TRUE,
year = 2020,
output = "wide")
pct_race <- raw_race |>
mutate(pct_hispanic = (hispanicE / total_popE),
pct_white_alone = (white_aloneE / total_popE),
pct_black_alone = (black_aloneE / total_popE),
pct_asian_alone = (asian_aloneE / total_popE))
ggplot(data = pct_race) +
geom_sf(aes(fill = pct_hispanic), color = NA) +
scale_fill_gradient(
low = "white", high = "red",
name = "Hispanic Population Density (%)",
labels = label_percent(scale = 100),
na.value = "white") +
theme_minimal() +
labs(
title = "Hispanic Population Density in Kings County, NY",
caption = "Data Source: ACS 2020",
subtitle = "Percent of Population Identifying as Hispanic") +
geom_sf(data = nabes, color = "black", fill = NA, lwd = 0.1) +
geom_sf(data = boros, color = "black", fill = NA, lwd = 0.3) +
coord_sf(datum = NA)
ggplot(data = pct_race) +
geom_sf(aes(fill = pct_white_alone), color = NA) +
scale_fill_gradient(
low = "white", high = "blue",
name = "White-alone Population Density (%)",
labels = label_percent(scale = 100),
na.value = "white") +
theme_minimal() +
labs(
title = "White Population Density in Kings County, NY",
caption = "Data Source: ACS 2020",
subtitle = "Percent of Population Identifying as White Alone") +
geom_sf(data = nabes, color = "black", fill = NA, lwd = 0.1) +
geom_sf(data = boros, color = "black", fill = NA, lwd = 0.3) +
coord_sf(datum = NA)
ggplot(data = pct_race) +
geom_sf(aes(fill = pct_black_alone), color = NA) +
scale_fill_gradient(
low = "white", high = "purple",
name = "Black-alone Population Density (%)",
labels = label_percent(scale = 100),
na.value = "white") +
theme_minimal() +
labs(
title = "Black Population Density in Kings County, NY",
caption = "Data Source: ACS 2020",
subtitle = "Percent of Population Identifying as Black Alone") +
geom_sf(data = nabes, color = "black", fill = NA, lwd = 0.1) +
geom_sf(data = boros, color = "black", fill = NA, lwd = 0.3) +
coord_sf(datum = NA)
ggplot(data = pct_race) +
geom_sf(aes(fill = pct_asian_alone), color = NA) +
scale_fill_gradient(
low = "white", high = "darkgreen",
name = "Asian-alone Population Density (%)",
labels = label_percent(scale = 100),
na.value = "white") +
theme_minimal() +
labs(
title = "Asian Population Density in Kings County, NY",
caption = "Data Source: ACS 2020",
subtitle = "Percent of Population Identifying as Asian Alone") +
geom_sf(data = nabes, color = "black", fill = NA, lwd = 0.1) +
geom_sf(data = boros, color = "black", fill = NA, lwd = 0.3) +
coord_sf(datum = NA)
As the maps show, each racial demographic is distributed throughout New York City in different densities. While there are obvious concentrations, indicated by darker colored census tracts, populations are visible as gradients, not blocks.
raw_summary_race <- get_acs(geography = "county",
variables = c(total_pop = "B01003_001",
hispanic = "B03002_012",
white_alone = "B03002_003",
black_alone = "B03002_004",
asian_alone = "B03002_006"),
state = "NY",
county = nyc_counties,
year = 2020,
output = "wide")
summary_race <- raw_summary_race |>
mutate(pct_hispanic = (hispanicE / total_popE) * 100,
pct_white_alone = (white_aloneE / total_popE) * 100,
pct_black_alone = (black_aloneE / total_popE) * 100,
pct_asian_alone = (asian_aloneE / total_popE) * 100) |>
select(County = NAME,
Total_Population = total_popE,
Percent_Hispanic = pct_hispanic,
Percent_White = pct_white_alone,
Percent_Black = pct_black_alone,
Percent_Asian = pct_asian_alone)
kable(summary_race, format = "html", digits = 2, caption = "Summary Table: Racial Percentages by County")
County | Total_Population | Percent_Hispanic | Percent_White | Percent_Black | Percent_Asian |
---|---|---|---|---|---|
New York County, New York | 1629153 | 25.68 | 46.85 | 12.24 | 12.04 |
Richmond County, New York | 475596 | 18.45 | 60.23 | 9.24 | 9.92 |
Bronx County, New York | 1427056 | 56.04 | 9.02 | 28.82 | 3.75 |
Kings County, New York | 2576771 | 18.87 | 36.42 | 29.28 | 11.81 |
Queens County, New York | 2270976 | 27.81 | 24.65 | 16.99 | 25.73 |
The summary table summarizes each county’s percentage of our specified racial demographics.
Created by Delaney Connor, 11-16-24