For this project, I visualized the temporal data of assaults in NYC over the years of 2014 - 2015. The plot below is a heatmap calendar with the darker red colors representing higher density of assaults.
All credit for the instructions and data go to Crime Mapping and Spatial Data Analysis using R by Juanjo Medina and Reka Solymosi.
Code can be found below.
library(readr)
library(dplyr)
library(lubridate)
library(ggeasy)
library(sf)
library(spacetime)
library(ggplot2)
library(ggfortify)
library(ggTimeSeries)
library(ggseas)
library(gganimate)
library(tmap)
agassault_ny = read_csv('https://raw.githubusercontent.com/maczokni/crime_mapping/master/data/agassault.csv')
agassault_ny$date <- date(agassault_ny$date_single)
agassault_ny_d <- agassault_ny %>%
group_by(date) %>% summarise(assaults = n())
ggplot_calendar_heatmap(
agassault_ny_d,
cDateColumnName = 'date',
cValueColumnName = 'assaults') +
xlab(NULL) +
ylab(NULL) +
scale_fill_continuous(low = '#FFFFFF',
high = '#8b0000') +
facet_wrap(~Year, ncol = 1) +
theme_minimal() +
ggtitle("New York City Assault Density by Calendar Time") +
easy_center_title()