Look at related crimes
library(dplyr)
library(ggplot2)
library(tidyr)
library(reshape2)
library(data.table)
library(DT)
library(d3heatmap)
library(lubridate)
library(xts)
library(dygraphs)
# Reading Input
d <- read.csv("../input/crime.csv", sep=",")
library(corrplot)
t <- d
t$Dispatch_Date_Time <- as.POSIXct(t$Dispatch_Date_Time)
t$month <- cut(t$Dispatch_Date_Time, breaks= "month")
t$Week <- cut(t$Dispatch_Date_Time, breaks= "week")
monthName <- function(x) strftime(x, '%b') # Jan, Feb etc.
t$month <- monthName(t$Dispatch_Date_Time)
counts <- summarise(group_by(t, Text_General_Code,month),Counts=length(Text_General_Code))
counts <- counts[order(counts$month),]
p <- dcast(counts,month ~ Text_General_Code, value.var = "Counts" )
p[is.na(p)] <- 0
# Make month row names
row.names(p) <- p$month
# Remove first
p = p[,-1]
M <- cor(p)
corrplot(M, type = "upper", order = "hclust",
tl.col = "black", tl.srt = 45,number.cex=0.75,tl.cex = 0.41)