summaryrefslogtreecommitdiffstats
path: root/R Scripts/plot-crime-data.R
diff options
context:
space:
mode:
Diffstat (limited to 'R Scripts/plot-crime-data.R')
-rw-r--r--R Scripts/plot-crime-data.R29
1 files changed, 16 insertions, 13 deletions
diff --git a/R Scripts/plot-crime-data.R b/R Scripts/plot-crime-data.R
index 13800cc..7bb768a 100644
--- a/R Scripts/plot-crime-data.R
+++ b/R Scripts/plot-crime-data.R
@@ -15,17 +15,10 @@ plot(data$Year,data$Homicide.Rate,type='l',col='#1f78b4',lwd=2,
###################
# load shootings data
# for lcc
-load('lcc.RData')
-vic_dates = as.Date(unlist(lcc_verts[,10:15]))
-vic_dates = vic_dates[!is.na(vic_dates)]
-vdh = hist(vic_dates, breaks='months')
-
-plot(vdh$mids,vdh$counts,type='l',col='#1f78b4',lwd=2,
- xlab='',ylab='Shootings',xaxt='n',cex.lab=.6,cex.axis=.6)
-axis(1,at=vdh$breaks[seq(1,102,12)],
- lab=2006:2014,cex.axis=.6)
-
-
+# load('lcc.RData')
+# vic_dates = as.Date(unlist(lcc_verts[,10:15]))
+# vic_dates = vic_dates[!is.na(vic_dates)]
+start_date = as.Date("2005-12-31")
# for all recorded shootings
shootings <- read.csv("shooting-data-withdate2.csv", header = T)
victims = shootings[shootings$INV_PARTY_TYPE_CD=="VIC",]
@@ -37,7 +30,7 @@ murders = read.csv("murder-victims-13nov.csv", header=T)
murders = murders[!is.na(murders$VICTIM_IR_NO),]
murders = murders[murders$INJURY_DESCR=="SHOT",]
murders = murders[match(unique(murders$VICTIM_IR_NO),murders$VICTIM_IR_NO),]
-murders = murders[as.Date(murders$INJURY_DATE,format='%m/%d/%y')>=start_date,]
+murders = murders[as.Date(murders$INJURY_DATE,format='%m/%d/%y')>start_date,]
murders$ir2 = paste("ir", murders$VICTIM_IR_NO)
# clear nonfatals that led to death
@@ -51,4 +44,14 @@ for(i in 1:dim(v)[1]){
}
victims = victims[-rows,]
-vic_dates = c(as.Date(murders$INJURY_DATE,format='%m/%d/%y'),as.Date(victims$INCIDENT_DATE,format='%m/%d/%y')) \ No newline at end of file
+vic_dates = c(as.Date(murders$INJURY_DATE,format='%m/%d/%y'),as.Date(victims$INCIDENT_DATE,format='%m/%d/%y'))
+
+vdh = hist(vic_dates, breaks='months')
+
+plot(vdh$mids[1:99],vdh$counts[1:99],type='l',col='#1f78b4',lwd=2,ylim=c(11,289),
+ xlab='',ylab='Shootings',xaxt='n',cex.lab=.6,cex.axis=.6)
+axis(1,at=vdh$breaks[seq(1,100,12)],
+ lab=2006:2014,cex.axis=.6)
+
+plot(colMeans(matrix(vdh$counts[1:96],ncol=12,byrow=T)))
+