#In this report, I build on my Week 3 homework by looking at the NYC shooting dataset. I explore patterns in shootings by time of day and borough, clean up the data, and then use plots to highlight some key trends.
shooting_data <- shooting_data %>% filter(!is.na(perp_race))
shooting_data <- shooting_data %>%
mutate(boro = str_to_lower(boro),
perp_race = str_to_lower(perp_race))
boro_counts <- shooting_data %>% count(boro)
shooting_data <- shooting_data %>%
mutate(
occur_time = hms::as_hms(occur_time),
hour = hour(occur_time),
time_of_day = case_when(
hour >= 6 & hour < 12 ~ "Morning",
hour >= 12 & hour < 18 ~ "Afternoon",
TRUE ~ "Night"
)
)
ggplot(shooting_data, aes(x = time_of_day, fill = time_of_day)) +
geom_bar() +
labs(title = "Shootings by Time of Day",
x = "Time of Day",
y = "Number of Shootings") +
theme_minimal(base_size = 14) +
scale_fill_brewer(palette = "Set2")
ggplot(shooting_data, aes(x = boro, fill = boro)) +
geom_bar() +
facet_wrap(~time_of_day) +
labs(title = "Shootings by Borough and Time of Day",
x = "Borough",
y = "Number of Shootings") +
theme_minimal(base_size = 14) +
scale_fill_brewer(palette = "Set3")
kable(boro_counts)
| boro | n |
|---|---|
| bronx | 6328 |
| brooklyn | 7404 |
| manhattan | 2953 |
| queens | 3069 |
| staten island | 680 |
NYC Open Data Shooting Incident Dataset ###This workflow makes it way easier to grab and clean big datasets. In my research I have to keep track of large datasets and I have to make sure my mentor understands what steps I am taking to clean the data we collect. The visualization helps me see the results in a clear way. My research is analzying people who believe in the Bad Apples Theory, and how that correlates with those who cause harm.