This report analyzes 911 call data from 2023, focusing on call categories, priority levels, district-wise distributions, and neighborhood-level statistics.
library(data.table)
library(ggplot2)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:data.table':
##
## between, first, last
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
setwd("/Users/rachelfoster/Documents/R VISUALIZATION")
filename <- "911_Calls_2023.csv"
df <- fread(filename, na.strings = c(NA, ""))
call_column <- "description" # Ensure this is the correct column
df <- df[!is.na(df[[call_column]]), ]
This bar chart displays the top 10 most common 911 call categories in 2023, showing which types of emergencies were reported most frequently.
call_count <- df[, .N, by = call_column][order(-N)]
top_10_calls <- call_count[1:10,]
top_10_calls$N <- as.numeric(top_10_calls$N)
ggplot(top_10_calls, aes(x = reorder(get(call_column), -N), y = N)) +
geom_bar(stat = "identity", colour = "black", fill = "gray76") +
labs(title = "Top 10 911 Call Categories in 2023",
x = "Call Type",
y = "Count") +
theme_minimal() +
theme(plot.title = element_text(hjust = 0.5, face="bold", size=14),
axis.text.x = element_text(angle = 45, hjust = 1))
This pie chart illustrates the distribution of 911 calls based on their assigned priority levels, giving an overview of the urgency of reported incidents.
priority_count <- df[, .N, by = priority]
ggplot(priority_count, aes(x = "", y = N, fill = priority)) +
geom_bar(stat = "identity", width = 1) +
coord_polar(theta = "y") +
labs(title = "911 Calls Distribution by Priority") +
theme_minimal() +
theme(axis.text.x = element_blank(),
axis.ticks = element_blank(),
panel.grid = element_blank()) +
scale_fill_brewer(palette = "Set2")
This heatmap visualizes the relationship between 911 calls and their priority levels across different districts. It helps to identify which districts had the highest volume of high-priority calls.
df_summary <- df %>%
group_by(district, priority) %>%
summarise(Count = n(), .groups = 'drop')
ggplot(df_summary, aes(x = district, y = priority, fill = Count)) +
geom_tile() +
scale_fill_gradient(low = "yellow", high = "red") +
labs(title = "Heatmap of 911 Calls by District & Priority",
x = "District",
y = "Priority Level",
fill = "N") +
theme_minimal() +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
This bar chart displays the number of 911 calls categorized by priority level, providing insight into the distribution of emergency severity.
df_summary <- df %>%
group_by(priority) %>%
summarise(Count = n(), .groups = 'drop')
ggplot(df_summary, aes(x = reorder(priority, -Count), y = Count)) +
geom_bar(stat = "identity", fill = "steelblue", color = "black") +
labs(title = "911 Calls by Priority Level",
x = "",
y = "Number of Calls") +
theme_minimal() +
theme(axis.text.x = element_text(angle = 45, hjust = 1, size = 10))
This bar chart highlights the top 10 neighborhoods with the highest number of 911 calls, indicating where emergency services were most frequently needed.
df_summary <- df %>%
group_by(Neighborhood) %>%
summarise(Count = n(), .groups = 'drop') %>%
arrange(desc(Count)) %>%
head(10)
ggplot(df_summary, aes(x = reorder(Neighborhood, -Count), y = Count)) +
geom_bar(stat = "identity", fill = "purple", color = "black") +
labs(title = "Top 10 Neighborhoods with 911 Calls",
x = "",
y = "Number of Calls") +
theme_minimal() +
theme(axis.text.x = element_text(angle = 45, hjust = 1, size = 10))
This report provides an insightful analysis of 911 calls in 2023, highlighting key trends in call types, priority levels, and geographical distribution. The visualizations offer a clear representation of how emergency services were utilized throughout the year.