This is an analysis with data visualization of the percentages of race distribution in New York City.
This is a census tract-level analysis of race in New York City. It provides visualizations of the total percentage of:
dp_2020 <- load_variables(2020, "pl", cache = T)
# P1_001N = TOTAL POP
# P2_002N = TOTAL pct hispanic or latino
# P2_006N = TOTAL pct black alone, not hispanic or latino
# P2_008N = TOTAL pct asian alone, not hispanic or latino
# P2_005N = TOTAL pct white alone, not hispanic or latino
race_vars = c("P1_001N","P2_002N", "P2_006N", "P2_008N", "P2_005N")
raw_race <- (get_decennial(geography = "tract",
state = 'NY',
variables = race_vars,
geometry = TRUE,
year = 2020,
output = "wide"))
race_dataframe <- raw_race |>
rename(total_pop = "P1_001N",
hisp_lat = "P2_002N",
black_not_hisp_lat = "P2_006N",
asian_not_hisp_lat = "P2_008N",
white_not_hisp_lat = "P2_005N") |>
mutate(percent_hisp_lat = hisp_lat/total_pop *100,
percent_black = black_not_hisp_lat / total_pop * 100,
percent_asian = asian_not_hisp_lat / total_pop * 100,
percent_white = white_not_hisp_lat / total_pop * 100) |>
separate(NAME, into = c("tract", "county"), sep = ",")
nyc_counties <- c(" New York County", " Kings County", " Queens County", " Bronx County", " Richmond County")
nyc_data <- race_dataframe |>
filter(county %in% nyc_counties)
### PERCENT HISPANIC OR LATINO
ggplot(nyc_data, aes(fill = percent_hisp_lat)) +
geom_sf() +
scale_fill_gradient(name = "Percent Hispanic or Latino",
low = "lightblue",
high = "darkolivegreen",
labels = percent_format(scale = 1)) +
labs(title = "Percent Hispanic or Latino by County")
This visualization shows the percentage of Hispanics or Latinos being concentrated in the Bronx, with the lesser percentage in Brooklyn.
### PERCENT BLACK, NOT HISPANIC OR LATINO
ggplot(nyc_data, aes(fill = percent_black)) +
geom_sf() +
scale_fill_gradient(name = "Percent Black, not Hispanic or Latino",
low = "lightblue",
high = "deeppink3",
labels = percent_format(scale = 1)) +
labs(title = "Percent Black, not Hispanic or Latino by County")
This visualization shows the percentage of Black, not Hispanic or Latino, being concentrated in the Bronx and Brooklyn, with the lesses percentage in Manhattan and Richmond (Staten Island).
### PERCENT ASAIN, NOT HISPANIC OR LATINO
ggplot(nyc_data, aes(fill = percent_asian)) +
geom_sf() +
scale_fill_gradient(name = "Percent Asian, not Hispanic or Latino",
low = "darkolivegreen2",
high = "pink",
labels = percent_format(scale = 1)) +
labs(title = "Percent Asian, not Hispanic or Latino by County")
This visualization shows the percentage of Asian, not Hispanic or Latino, being concentrated in Queens, with the lesser percentage being in the Bronx.
### PERCENT WHITE, NOT HISPANIC OR LATINO
ggplot(nyc_data, aes(fill = percent_white)) +
geom_sf() +
scale_fill_gradient(name = "Percent White, not Hispanic or Latino",
low = "mediumpurple1",
high = "red",
labels = percent_format(scale = 1)) +
labs(title = "Percent White, not Hispanic or Latino by County")
This visualization shows the percentage of White, not Hispanic or Latino, concentrated in Staten Island and Manhattan, with the lesser percentage being in the Bronx.
I used completely different colors in my visualizations instead of shades of one color, in order to see the stark differences and concentrations of race, and where there is more of a mix.
** I messed around with this for awhile to address the messups in the final output, but I was unable to figure it out.