Exploring the percentages of different races in Jackson Heights

library(tidyverse)
library(tidycensus)
library(sf)
library(scales)
library(viridis)
library(plotly)
## Warning: package 'plotly' was built under R version 4.3.2
library (knitr)
## Warning: package 'knitr' was built under R version 4.3.2

Methods

Borough boundaries are represented with a shapefile that was downloaded from NYC Open Data.

Census tract boundaries and data are from the 2016-2020 5-year American Community Survey, accessed with the tidyverse R package. Census data includes:

The number of people of different races namely : Asian, Hispanic and Black The total population for each census tract was calculated and the census tracts with no residents were removed.

boros <- st_read("C:/Users/leah/Desktop/DUE/SEM 1/METHODS/class_data/methods1/part2/data/raw/Geo/Borough Boundaries.geojson")


raw_race_data = get_decennial(geography = "tract", 
                                 variables = c(tot_pop = "P2_001N",
                                               tot_white_not_his = "P2_005N",
                                               tot_black_not_his = "P2_006N",
                                               tot_asian_not_his = "P2_008N",
                                               tot_his_or_latino = "P2_002N"),
                              state = "NY",
                              county = "Queens",
                              geometry = T,
                                 year = 2020,
                                 output = "wide")
## Warning: • You have not set a Census API key. Users without a key are limited to 500
## queries per day and may experience performance limitations.
## ℹ For best results, get a Census API key at
## http://api.census.gov/data/key_signup.html and then supply the key to the
## `census_api_key()` function to use it throughout your tidycensus session.
## This warning is displayed once per session.
Race_data <- raw_race_data |>
  mutate (pct_hisp_latino = tot_his_or_latino/tot_pop,
          pct_black_alone = tot_black_not_his/tot_pop,
          pct_white_alone = tot_white_not_his/tot_pop,
          pct_asian_alone = tot_asian_not_his/tot_pop) |>
  separate (NAME, into = c("tract", "place"), sep = ",") |>
  select (tract,tot_pop,tot_white_not_his,tot_black_not_his,tot_asian_not_his,tot_his_or_latino,
          pct_hisp_latino,pct_black_alone,pct_white_alone,pct_asian_alone)
## Warning: Expected 2 pieces. Additional pieces discarded in 725 rows [1, 2, 3, 4, 5, 6,
## 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, ...].

Results

 ggplot()  + 
  geom_sf(data = Race_data, 
          mapping = aes(fill = pct_black_alone,
                        text = paste0(tract, ":",
                                      "<br>Percent of Black Population: ",
                                      percent(pct_black_alone, accuracy=1))),
          color = "transparent") +
  theme_void() +
  scale_fill_distiller(breaks=c(0, .2, .4, .6, .8, 1),
                       direction = 1,
                       na.value = "#fafafa",
                      
                       name="Percent of Black Population (%)",
                       labels=percent_format(accuracy = 1L)) +
  labs(
    title = "Queens, Black Population by Census Tract",
    caption = "Source: Decennial Survey, 2016-20"
  ) + 
  geom_sf(data = boros |> filter(boro_name == "Queens"), 
          color = "black", fill = NA, lwd = .5)
## Warning in layer_sf(geom = GeomSf, data = data, mapping = mapping, stat = stat,
## : Ignoring unknown aesthetics: text

ggplot()  + 
  geom_sf(data = Race_data, 
          mapping = aes(fill = pct_white_alone,
                        text = paste0(tract, ":",
                                      "<br>Percent of White Population: ",
                                      percent(pct_white_alone, accuracy=1))),
          color = "transparent") +
  theme_void() +
  scale_fill_distiller(breaks=c(0, .2, .4, .6, .8, 1),
                       direction = 1,
                       na.value = "#fafafa",
                      
                       name="Percent of White Population (%)",
                       labels=percent_format(accuracy = 1L)) +
  labs(
    title = "Queens, White Population by Census Tract",
    caption = "Source: Decennial Survey, 2016-20"
  ) + 
  geom_sf(data = boros |> filter(boro_name == "Queens"), 
          color = "black", fill = NA, lwd = .5)
## Warning in layer_sf(geom = GeomSf, data = data, mapping = mapping, stat = stat,
## : Ignoring unknown aesthetics: text

ggplot()  + 
  geom_sf(data = Race_data, 
          mapping = aes(fill = pct_asian_alone,
                        text = paste0(tract, ":",
                                      "<br>Percent of Asian Population: ",
                                      percent(pct_asian_alone, accuracy=1))),
          color = "transparent") +
  theme_void() +
  scale_fill_distiller(breaks=c(0, .2, .4, .6, .8, 1),
                       direction = 1,
                       na.value = "#fafafa",
                      
                       name="Percent of Asian Population (%)",
                       labels=percent_format(accuracy = 1L)) +
  labs(
    title = "Queens, Asian Population by Census Tract",
    caption = "Source: Decennial Survey, 2016-20"
  ) + 
  geom_sf(data = boros |> filter(boro_name == "Queens"), 
          color = "black", fill = NA, lwd = .5)
## Warning in layer_sf(geom = GeomSf, data = data, mapping = mapping, stat = stat,
## : Ignoring unknown aesthetics: text

ggplot()  + 
  geom_sf(data = Race_data, 
          mapping = aes(fill = pct_hisp_latino,
                        text = paste0(tract, ":",
                                      "<br>Percent of Hispanic or Latino Population: ",
                                      percent(pct_hisp_latino, accuracy=1))),
          color = "transparent") +
  theme_void() +
  scale_fill_distiller(breaks=c(0, .2, .4, .6, .8, 1),
                       direction = 1,
                       na.value = "#fafafa",
                      
                       name="Percent of Hispanic or Latino Population (%)",
                       labels=percent_format(accuracy = 1L)) +
  labs(
    title = "Queens, Hispanic or Latino Population by Census Tract",
    caption = "Source: Decennial Survey, 2016-20"
  ) + 
  geom_sf(data = boros |> filter(boro_name == "Queens"), 
          color = "black", fill = NA, lwd = .5)
## Warning in layer_sf(geom = GeomSf, data = data, mapping = mapping, stat = stat,
## : Ignoring unknown aesthetics: text

### Analysis I was interested in analyzing the racial composition of Jackson Heights in Queens

nabes <- st_read("C:/Users/leah/Desktop/DUE/SEM 1/METHODS/class_data/methods1/part2/data/raw/Geo/nynta2020_23c/nynta2020.shp")
Race_data_2263 <- st_transform(Race_data, 2263)
st_crs(Race_data_2263)

nabes_selected <- nabes |>
  select(BoroCode, BoroName, NTA2020, NTAName)

Joining data to create a data frame for Jackson Heights

Race_data_nabes <- Race_data_2263 |>
  st_join(nabes_selected, 
          left = TRUE,
          join = st_intersects,
          largest = TRUE)
## Warning: attribute variables are assumed to be spatially constant throughout
## all geometries

Jackson Heights

ggplot(data = Race_data_nabes |> 
         filter(NTAName == "Jackson Heights"),
       mapping = aes(fill = pct_black_alone))  + 
  geom_sf(color = "black",
          lwd = 0) +
  theme_void() +
  scale_fill_distiller(breaks=c(0, .2, .4, .6, .8, 1),
                       direction = 1,
                       na.value = "transparent",
                       name="Percent of Black population in Jackson Heights (%)",
                       labels=percent_format(accuracy = 1L)) +
  labs(
    title = "Jackson Heights, Queens , Black population by Census Tract",
    caption = "Source: Decennial census, 2016-20"
  ) + 
  geom_sf(data = nabes |> filter(NTAName == "Jackson Heights "), 
          color = "black", fill = NA, lwd = 0.5)

ggplot(data = Race_data_nabes |> 
         filter(NTAName == "Jackson Heights"),
       mapping = aes(fill = pct_asian_alone))  + 
  geom_sf(color = "black",
          lwd = 0) +
  theme_void() +
  scale_fill_distiller(breaks=c(0, .2, .4, .6, .8, 1),
                       direction = 1,
                       na.value = "transparent",
                       name="Percent of Asian population in Jackson Heights (%)",
                       labels=percent_format(accuracy = 1L)) +
  labs(
    title = "Jackson Heights, Queens , Asian population by Census Tract",
    caption = "Source: Decennial census, 2016-20"
  ) + 
  geom_sf(data = nabes |> filter(NTAName == "Jackson Heights "), 
          color = "black", fill = NA, lwd = 0.5)

ggplot(data = Race_data_nabes |> 
         filter(NTAName == "Jackson Heights"),
       mapping = aes(fill = pct_white_alone))  + 
  geom_sf(color = "black",
          lwd = 0) +
  theme_void() +
  scale_fill_distiller(breaks=c(0, .2, .4, .6, .8, 1),
                       direction = 1,
                       na.value = "transparent",
                       name="Percent of White population in Jackson Heights (%)",
                       labels=percent_format(accuracy = 1L)) +
  labs(
    title = "Jackson Heights, Queens , White population by Census Tract",
    caption = "Source: Decennial census, 2016-20"
  ) + 
  geom_sf(data = nabes |> filter(NTAName == "Jackson Heights "), 
          color = "black", fill = NA, lwd = 0.5)

ggplot(data = Race_data_nabes |> 
         filter(NTAName == "Jackson Heights"),
       mapping = aes(fill = pct_hisp_latino))  + 
  geom_sf(color = "black",
          lwd = 0) +
  theme_void() +
  scale_fill_distiller(breaks=c(0, .2, .4, .6, .8, 1),
                       direction = 1,
                       na.value = "transparent",
                       name="Percent of Hispanic or Latino population in Jackson Heights (%)",
                       labels=percent_format(accuracy = 1L)) +
  labs(
    title = "Jackson Heights, Queens , Hispanic or Latino population by Census Tract",
    caption = "Source: Decennial census, 2016-20"
  ) + 
  geom_sf(data = nabes |> filter(NTAName == "Jackson Heights "), 
          color = "black", fill = NA, lwd = 0.5)

In Jackson Heights, the Hispanic or Latino population stands out as the predominant ethnic group, with varying concentrations across different areas. Notably, the demographic maps vividly illustrate the prevalence of Hispanic individuals, emphasizing their majority status in terms of race within the community. These maps not only reveals the diversity of Jackson Heights but also reveal distinct pockets of concentration for other racial groups. The demographic distribution is not uniform, and certain races exhibit localized concentrations within specific areas of the neighborhood.