diff options
| author | Ben Green <bgreen@g.harvard.edu> | 2015-09-29 18:36:38 -0400 |
|---|---|---|
| committer | Ben Green <bgreen@g.harvard.edu> | 2015-09-29 18:36:38 -0400 |
| commit | 3969a594c49e58aafe04ff352b02d0d61eb228cf (patch) | |
| tree | 279dc1f33991d6547a074d3c63b012797de2830a /R Scripts/arrest-vs-infection-times.R | |
| parent | fdaeb646dc262807b7bca60354649e15baa60d31 (diff) | |
| download | criminal_cascades-3969a594c49e58aafe04ff352b02d0d61eb228cf.tar.gz | |
finalizing plots!
Diffstat (limited to 'R Scripts/arrest-vs-infection-times.R')
| -rw-r--r-- | R Scripts/arrest-vs-infection-times.R | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/R Scripts/arrest-vs-infection-times.R b/R Scripts/arrest-vs-infection-times.R index 222be3e..7c0bfcf 100644 --- a/R Scripts/arrest-vs-infection-times.R +++ b/R Scripts/arrest-vs-infection-times.R @@ -1,6 +1,38 @@ library(igraph) -setwd('~/Documents/Cascade Project/Raw Data/') +setwd('~/Documents/Violence Cascades/Raw Data/') + +person_verts = get.data.frame(person,'vertices') +vics = person_verts$vic +vic_verts = person_verts[vics,14:19] +first_vics = apply(vic_verts,1,min,na.rm=T) + + +load('arrests.RData') +arr = arrests[order(arrests$date2),] +arr = arr[match(unique(arr$ir2),arr$ir2),] +arr = arr[match(rownames(person_verts),arr$ir2),] +arr = arr[vics,] +offset = 16802 +first_arrests = as.numeric(arr$date2) - offset + +lag = first_vics - first_arrests +hist(lag,100,col='') +h = hist(lag,150,col='#1f78b4',border=NA,axes=T, + xlab='',ylab='Frequency',main=NULL) +box(lwd=1.1) + + + + + + + + + + + +#### OLD VERSION ##### Load arrest data arrests <- read.csv("2006to2014arrests2.csv", header=T, colClass=c("character")) arrests$ir2 <- paste("ir", arrests$ir_no) @@ -41,3 +73,4 @@ murders = murders[murders$ir2 %in% arrests$ir2,] mur_dates = murders$INJURY_DATE arrest_dates = sub.arrests$dates[match(murders$ir2, sub.arrests$individuals)] sum(mur_dates==arrest_dates) + |
