Before visualization could take place an examination of the data occurred to confirm the quality of the information. The source data obtained from the City of Richmond’s website was exceptionally clean and did not require renaming to perform data processing. The bulk of data wrangling occurred during the creation of the visualizations in order to highlight areas of the story of 2023 crime in the city.
These research questions represent an initial glance at the story of 2023 crime in Richmond. This dataset tells the “what” and “where” of the story. What crimes were committed and where those crimes were most likely to take place. The below code snippets utilizes the scripting langauge R to wrangle the data and visualize the answers to the posed research questions.
# This section of code outlines the R packages utilized in the data maintenance and visualization portions of this report.
# The below packages were loaded in to help read and plot the data
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ ggplot2 3.5.1 ✔ tibble 3.2.1
## ✔ lubridate 1.9.4 ✔ tidyr 1.3.1
## ✔ purrr 1.0.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(here)
## here() starts at C:/GEOG588/Week1/RYouWithMe
library(dplyr)
# ggplot2 is the main R package used for visualization
library(ggplot2)
# The below line of code reads the data to variable "crime23"
crime23 <- read.csv(here("2023_RVA_crime_cleaned.csv"))
# Find below a brief glimpse of the data
head(crime23)
## neighborhood homicide sex_offense robbery assault burglary vice
## 1 ANCAROWS LANDING 0 0 1 3 0 1
## 2 BEAUFONT 0 2 1 9 4 2
## 3 BELLE AND MAYO ISLANDS 0 1 2 5 0 0
## 4 BELLEMEADE 4 3 4 70 25 3
## 5 BELLEVUE 0 0 0 4 2 0
## 6 BELMONT WOODS 0 0 0 1 0 1
## theft veh_theft other
## 1 6 3 29
## 2 9 2 45
## 3 6 0 15
## 4 82 35 231
## 5 36 4 59
## 6 9 0 12
This report seeks to answer the question of which crimes were most common in Richmond, which neighborhoods experienced the most crime, and which neighborhood suffered the most violence in 2023? To plot these metrics the ggplot2 package was installed and used to expand beyond the RStudio standard functionality. ### Plot 1. Which Richmond City neighborhood experienced the most reported crime in 2023? To tell the story of crime in Richmond the locations with the highest crime reports needed to be found.
# Plot 1:
# This graph plots mean crime amounts for the ten neighborhoods that experienced the highest mean amounts of crime in 2023
top10_crime <- crime23 %>%
# Neighborhoods were the focus of this graph so group_by was used to focus on that data
group_by(neighborhood) %>%
# summarize was used to generate a mean crime amount so the average crime by neighborhood could be displayed
summarize(total_crime = (homicide + sex_offense + assault + robbery + burglary + vice + theft + veh_theft + other),
mean_crime = mean(total_crime, na.rm = TRUE)) %>%
arrange(desc(mean_crime)) %>% #sorting mean_crime in descending order
slice_head(n = 10) # choosing to focus on ten neighborhoods to visual clarity
# I found it easier to assign top10_crime as a variable before plotting instead of fitting the entire plotting process inside one pipe
top10_crime %>%
ggplot(aes(x = reorder(neighborhood, mean_crime), y = mean_crime, fill = total_crime)) +
geom_col() +
coord_flip() +
theme_light() +
# a pink to red color gradient was chosen to signal urgency and highlight the neighborhood with the highest crime reports
scale_fill_gradient(name = "Total Crime", low = "pink", high = "red") +
labs(title = "Mean crime amounts for the 10 Richmond nieghborhoods \nthat had the most amount of crime in 2023",
subtitle = "Please not there are 149 neighborhoods in Richmond, this graph \nonly represents the ten that experienced the most crime.",
caption = "Source Data: https://apps.richmondgov.com/applications/CrimeInfo",
x = "Neighborhood",
y = "Mean Crime Amounts")
This plot highlights the neighborhood known as “The Fan” as having the
highest amount of reported crimes in 2023. This trend reflects
population growth, apartments in “The Fan” are in high demand as the
neighborhood is centrally located in the city being equal distance from
the state capital, the largest university in the city, and the shopping
center. The high population and central location suggests it experiences
the highest amount of foot traffic out of any neighborhood in the city.
Next steps for this plot would be to normalize over population by
neighborhood to identify which neighborhood has the highest crime
reported per population.
# Plot 2.
# This graph plots mean violent crime amounts for the ten neighborhoods that experienced the highest reports for violent crime in 2023
top_violent_crime <- crime23 %>%
group_by(neighborhood) %>%
summarize(violent_crime = (homicide + sex_offense + assault),
total_crime = (homicide + sex_offense + assault + robbery + burglary + vice + theft + veh_theft + other),
violent_crime_percent = ((violent_crime / total_crime) * 100)) %>%
arrange(desc(violent_crime)) %>%
# The ten highest violent crime values were selected to be displayed on the graph to conserve visual space. All 149 neighborhoods would not have presented well to display this metric.
slice_head(n = 10)
# The script below is how the plot of violent crime was created for Richmond. A .png file was chosen to be included to meet the requirements of the assignment and display cleaner neighborhood labels.
top_violent_crime %>%
ggplot(aes(x = reorder(neighborhood, -violent_crime), y = violent_crime, fill = violent_crime)) +
geom_col() +
theme_light() +
scale_fill_gradient(name = "Violent Crime", low = "pink", high = "red") +
labs(title = "Mean amounts of violent crime for the 10 Richmond neighborhoods with highest \nviolent crime reports in 2023",
subtitle = "Violent crime was defined by this report as including homicide,\n sexual offenses, and assault",
caption = "Source Data: https://apps.richmondgov.com/applications/CrimeInfo",
x = "Neighborhood",
y = "Mean Violent Crime")
This plot ranks “The Fan” as highest again for crime reports. Violent
crime was filtered to include homicide, assault, and sexual offenses. An
interesting change in this plot, when compared to the first, is the
increase in violent crime reports for the neighborhood of “Gilpin.”
Gilpin is a relatively small neighborhood in the city of Richmond, which
was heavily redeveloped to accommodate public housing. While this plot
aligns with predictions made of “The Fan” having the highest violent
crime, proportionate to its population, this visualization suggests that
additional considerations need to be factored in to try and explain the
rise of specifically violent crime in the areas displayed.
# Plot 3
crime23 %>%
# a pivot_longer solution was the perfect tool for display crime_types in a longer style
pivot_longer(cols = homicide:veh_theft, names_to = "crime_type", values_to = "crime_count") %>%
# crime_type was chosen to be used as the color gradient
ggplot(aes(x = crime_type, y = crime_count, color = crime_type)) +
geom_jitter() + # a jitter plot was chosen to display the points as it added enough "noise" to be more visualy interesting than a traditional point graph
theme_light() +
labs(title = "Count by crime type for the city of Richmond, 2023",
caption = "Source Data: https://apps.richmondgov.com/applications/CrimeInfo",
x = " Crime Type",
y = "Crime Count")
As seen in plot 3 the crime with the highest reported occurrences was
theft. Assault, vehicle theft, and vice followed in frequency. These
figures display trends that paint a story of the crime ecosystem in
Richmond City. Inflation and gentrification has dramatically raised the
cost of living in the city over the past five years. Mounting financial
pressures could explain the high trends of theft. Large educational
institutions in the city also attract a high population of young adults,
Richmond has a higher than average population of individuals under the
age of 25. Young populations tend to display more disregard for petty
crime like theft.
This information and data visualizations do not paint a complete picture of the crime ecosystem experienced by the city of Richmond. They do start to create an image of the typical crimes the city faces and the areas that are most impacted. Next steps to explore the crime trends of Richmond include obtaining historic crime data, understanding multi-year trends will highlight the potential impacts of demographic and socioeconomic changes. Additionally, obtaining spatial data to map out the crime impacts will provide an insightful perspective in the scope of crime in the city.