title: “NYC Police Data Dashboard”
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: fill

Column

Arrests by Age Group and Borough

arrest_demo <- arrest_data %>%
  group_by(arrest_boro, age_group, perp_race, perp_sex) %>%
  summarise(count = n()) %>%
  arrange(desc(count))
## `summarise()` has grouped output by 'arrest_boro', 'age_group', 'perp_race'.
## You can override using the `.groups` argument.
ggplot(arrest_demo, aes(x = age_group, y = count, fill = arrest_boro)) +
  geom_bar(stat = "identity", position = "dodge") +
  labs(title = "Arrests by Age Group and Borough", x = "Age Group", y = "Number of Arrests") +
  theme_minimal()

Explanation: This bar chart shows that most arrests occur among individuals aged 18–34, especially in boroughs like the Bronx and Brooklyn. It highlights the need for youth-focused intervention programs and suggests where city resources should be prioritized. Why it matters: Highlights where youth-focused programs may be most impactful.

Top 10 Crime Types by Borough

crime_type <- arrest_data %>%
  group_by(arrest_boro, ofns_desc) %>%
  summarise(count = n()) %>%
  group_by(arrest_boro) %>%
  slice_max(count, n = 10)
## `summarise()` has grouped output by 'arrest_boro'. You can override using the
## `.groups` argument.
ggplot(crime_type, aes(x = reorder(ofns_desc, -count), y = count, fill = arrest_boro)) +
  geom_bar(stat = "identity", position = "dodge") +
  labs(title = "Top Crime Types by Borough", x = "Crime Type", y = "Count") +
  theme(axis.text.x = element_text(angle = 45, hjust = 1))

Explanation: This graph reveals the most frequent types of crimes committed in each borough, showing patterns like drug-related and assault offenses dominating in certain areas. It’s useful for tailoring borough-specific policing strategies and crime prevention initiatives. Why it matters: Informs resource allocation and local crime prevention strategies.

Column

Arrests by Race (Pie Chart)

race_summary <- arrest_data %>%
  group_by(perp_race) %>%
  summarise(total = n())

ggplot(race_summary, aes(x = "", y = total, fill = perp_race)) +
  geom_bar(stat = "identity", width = 1) +
  coord_polar("y") +
  labs(title = "Arrests by Race in NYC", fill = "Race") +
  theme_minimal()

Explanation: The pie chart illustrates the racial breakdown of arrests in NYC, with disproportionate representation among certain racial groups. This visualization raises questions about potential racial bias in policing and can support equity-focused policy discussions. Why it matters: Supports discussion around equity and justice.

Shooting Hotspots by Precinct

hotspots <- shooting_data %>%
  group_by(boro, precinct) %>%
  summarise(total_shootings = n())
## `summarise()` has grouped output by 'boro'. You can override using the
## `.groups` argument.
ggplot(hotspots, aes(x = reorder(precinct, -total_shootings), y = total_shootings, fill = boro)) +
  geom_bar(stat = "identity") +
  labs(title = "Shooting Hotspots by Precinct", x = "Precinct", y = "Total Shootings") +
  theme(axis.text.x = element_text(angle = 45, hjust = 1))

Explanation: This chart identifies precincts with the highest number of shootings, particularly concentrated in specific boroughs like the Bronx. It helps officials target anti-violence programs and deploy law enforcement strategically to high-risk areas. Why it matters: Helps prioritize areas for violence reduction strategies.

Arrests & Income Inequality by Borough

income_inequality <- data.frame(
  arrest_boro = c("B", "Q", "M", "S", "BK"),
  gini = c(0.52, 0.46, 0.54, 0.43, 0.48)
)

merged <- arrest_data %>%
  group_by(arrest_boro) %>%
  summarise(total_arrests = n()) %>%
  left_join(income_inequality, by = "arrest_boro") %>%
  mutate(inequality_level = ifelse(gini < 0.5, "Low Inequality", "High Inequality"))

ggplot(merged, aes(x = arrest_boro, y = total_arrests, fill = inequality_level)) +
  geom_bar(stat = "identity") +
  labs(title = "Arrests vs. Income Inequality", x = "Borough", y = "Arrests", fill = "Inequality Level") +
  theme_minimal()

Explanation: This bar chart compares total arrests to the income inequality level (via Gini coefficient) in each borough, revealing a trend where higher inequality aligns with more arrests. It underscores the link between economic disparity and crime, supporting the need for social policy reforms alongside policing. Why it matters: Highlights economic disparities that may correlate with policing trends.