Project Overview

This analysis examines shooting incidents in New York City based on historic data from the NYPD. We will explore trends in incidents over the years and by region, along with a demographic breakdown of victims and shooters.

Data Source

The data used in this analysis is retrieved from the NYC Open Data portal: - Dataset URL: NYPD Shooting Incident Data

url <- "https://data.cityofnewyork.us/api/views/833y-fsy8/rows.csv?accessType=DOWNLOAD"

Load necessary libraries

library(readr)  
library(tidyverse)
library(dplyr)
library(lubridate)
library(ggplot2)

Data Cleaning and Preparation

Remove unnecessary columns and rename for clarity

We remove columns that are irrelevant for our analysis and rename others for better clarity.
## # A tibble: 6 × 10
##   Incident_date Region   Location Murder Shooter_age_group Shooter_sex
##   <date>        <chr>    <chr>    <lgl>  <chr>             <chr>      
## 1 2021-08-09    BRONX    <NA>     FALSE  <NA>              <NA>       
## 2 2018-04-07    BROOKLYN <NA>     TRUE   25-44             M          
## 3 2022-12-02    BRONX    STREET   FALSE  (null)            (null)     
## 4 2006-11-19    BROOKLYN <NA>     TRUE   UNKNOWN           U          
## 5 2010-05-09    BRONX    <NA>     TRUE   25-44             M          
## 6 2012-07-22    BRONX    <NA>     FALSE  18-24             M          
## # ℹ 4 more variables: Shooter_race <chr>, Victim_age_group <chr>,
## #   Victim_sex <chr>, Victim_race <chr>

Analysis

Shooting Incidents Trend Over Years

We add a column for the year and summarize the number of incidents by year and region.

## # A tibble: 6 × 3
## # Groups:   Year [2]
##    Year Region        Count
##   <dbl> <chr>         <int>
## 1  2006 BRONX           568
## 2  2006 BROOKLYN        850
## 3  2006 MANHATTAN       288
## 4  2006 QUEENS          296
## 5  2006 STATEN ISLAND    53
## 6  2007 BRONX           533

Heatmap of Incidents by Year and Region

The following heatmap visualizes shooting incidents across different regions over the years.

Line Chart of Incidents Over Years by Region

Pie Chart of Incidents by Region (Year 2006)

This pie chart illustrates the distribution of incidents across regions for the year 2006. By changing the year of inident within the code you can view other year’s data.