The data is downloaded from ArcGIS Hub and the address is:
https://hub.arcgis.com/datasets/9e459776d4c3463cad52fe6003ffc668_0/data
Before cleaning the data, I saved the dataset into a file, so it is no need to download it every time when I restart R.
ala <- readOGR(‘https://opendata.arcgis.com/datasets/9e459776d4c3463cad52fe6003ffc668_0.geojson’)
geojson_write(ala, file = ‘Alameda_Crime_Data.geojson’)
After cleaning the data, I saved it into a .Rds file, and here is where I start to analyze the data.
library(pacman)
p_load(tidyverse, DT, dygraphs, plotly, lubridate, xts)
source('Chen_Xiaodan_Stat694_Project.R')
alam <- read_rds('alameda_crime_data.Rds')
alam <- alam %>% mutate(date = as.Date.POSIXct(time))
head(alam)
Here is the order of crime numbers base on CrimeCode.
alam %>%
select(CrimeCode) %>%
group_by(CrimeCode) %>%
count() %>%
arrange(desc(n))
The datatable help us to search the relative information about each CrimeCode.
datatable(alam)
## Warning in instance$preRenderHook(instance): It seems your data is too big
## for client-side DataTables. You may consider server-side processing: https://
## rstudio.github.io/DT/server.html