Short description of analysis: Mapping asthma emergency department visits in NYC
library(tidyverse)
library(tidycensus)
library(sf)
library(scales)
library(viridis)
library(plotly)
library(here)
Data was downloaded from NYC Open Data.
Community District boundaries are represented with a shapefile that was downloaded from NYC Open Data.
NYC Open Data includes ‘Number of adults admitted to ED for asthma, Estimated annual rate per 10,000, Age adjusted rate per 10,000’
The Estimated annual rate per 10,000 for each community district was mapped and Joint Interest Areas: public parks, waterways, major governmental installations etc. were removed as they do not include residents.
read_csv("/Users/izzygroenewegen/Documents/F23/Methods 1/methods1/part2/scripts/NYC_EH_Data Portal_Asthma_emergency_department_visits.csv")
## Rows: 792 Columns: 8
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (5): GeoType, Geography, Age-adjusted rate per 10,000, Estimated annual ...
## dbl (3): Time, GeoID, GeoRank
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
asthma_ed_visits_adults <- read_csv("/Users/izzygroenewegen/Documents/F23/Methods 1/methods1/part2/scripts/NYC_EH_Data Portal_Asthma_emergency_department_visits.csv")|>
filter(Time == 2019,
GeoType == "CD")
## Rows: 792 Columns: 8
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (5): GeoType, Geography, Age-adjusted rate per 10,000, Estimated annual ...
## dbl (3): Time, GeoID, GeoRank
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
#import community district geo data
community_districts <- st_read("/Users/izzygroenewegen/Documents/F23/Methods 1/methods1/part2/data/raw/geo/Community_Districts.geojson")|>
rename(GeoID = boro_cd)|>
mutate(GeoID = as.numeric(GeoID))
## Reading layer `Community_Districts' from data source
## `/Users/izzygroenewegen/Documents/F23/Methods 1/methods1/part2/data/raw/geo/Community_Districts.geojson'
## using driver `GeoJSON'
## Simple feature collection with 71 features and 3 fields
## Geometry type: MULTIPOLYGON
## Dimension: XY
## Bounding box: xmin: -74.25559 ymin: 40.49613 xmax: -73.70001 ymax: 40.91553
## Geodetic CRS: WGS 84
asthma_ed_cd <- community_districts|>
left_join(asthma_ed_visits_adults, by = "GeoID")|>
mutate(`Estimated annual rate per 10,000` = as.numeric(`Estimated annual rate per 10,000`))|>
filter(`Estimated annual rate per 10,000` > 0)
Results are mapped by Community District. Color scale is Red, with darker reds indicating higher rates of admission to ED for asthma related emergencies.
ggplot(data = asthma_ed_cd, mapping = aes(fill = `Estimated annual rate per 10,000`)) +
geom_sf(color = "#ffffff") +
theme_void()+
scale_fill_distiller(breaks=c(0,.2,.4,.6,.8,1),
palette = "Reds",
direction = 1,
na.value = "white",
name="Asthma Emergency Visits, Estimated annual rate per 10,000",
labels=percent_format(accuracy = 1L))+
labs(
title = "Emergency Visits for Asthma per 10,000 Adults",
caption = "Source: NYC EH Data Portal Asthma Emergency Department 2019")
The map above indicates that the South Bronx has the highest asthma rates.
asthma_ed_map <- ggplot() +
geom_sf(data = asthma_ed_cd,
mapping = aes(fill = `Estimated annual rate per 10,000`,
text = paste0(Geography,":",
"<br>Asthma Emergency Visits Estimated annual rate per 10,000: ",
scales::percent(`Estimated annual rate per 10,000`, accuracy=1))),
color = "transparent") +
theme_void()+
scale_fill_distiller(breaks=c(0,.2,.4,.6,.8,1),
palette = "Reds",
direction = 1,
na.value = "white",
name="Asthma Emergency Visits, Estimated annual rate per 10,000",
labels=percent_format(accuracy = 1L))+
labs(
title = "Emergency Visits for Asthma per 10,000 Adults",
caption = "Source: NYC EH Data Portal Asthma Emergency Department 2019")
## Warning in layer_sf(geom = GeomSf, data = data, mapping = mapping, stat = stat,
## : Ignoring unknown aesthetics: text
Unfortunately, every time I tried to add a tooltip, I would receive the above error. Alas.