Wednesday, August 5, 2015

An Analysis of Whatcom County Jail Press Releases: Word Counts, Word Clouds, Relational Graphs,Criminogenic Cycles: Part I

Political piece is here



# Code to examine booking press release information for Whatcom County Jail 
# Code to examine crime patterns; Does not contain web query routines.
# 8:33 PM Tuesday, July 28, 2015 -RMF
# Further note: I wrote a lot of code here... 
# I wonder if proper use of dplyr or aggregate could obviate most of this...

# Sources
# http://www.co.whatcom.wa.us/258/Inmate-Databases

library(dplyr)
library(lattice)

#... Collect Years
Years <- c(2011,2012,2013,2014,2015)
setwd("C:/JoyGilfilen/Bookings/2015")
Crimes2015 <- read.csv("CrimeASCII.csv", fill=FALSE, header = FALSE, strip.white = TRUE, sep = ",", quote = "", stringsAsFactors = FALSE)
setwd("C:/JoyGilfilen/Bookings/2014")
Crimes2014 <- read.csv("CrimeASCII.csv", fill=FALSE, header = FALSE, strip.white = TRUE, sep = ",", quote = "", stringsAsFactors = FALSE)
setwd("C:/JoyGilfilen/Bookings/2013")
Crimes2013 <- read.csv("CrimeASCII.csv", fill=FALSE, header = FALSE, strip.white = TRUE, sep = ",", quote = "", stringsAsFactors = FALSE)
setwd("C:/JoyGilfilen/Bookings/2012")
Crimes2012 <- read.csv("CrimeASCII.csv", fill=FALSE, header = FALSE, strip.white = TRUE, sep = ",", quote = "", stringsAsFactors = FALSE)
setwd("C:/JoyGilfilen/Bookings/2011")
Crimes2011 <- read.csv("CrimeASCII.csv", fill=FALSE, header = FALSE, strip.white = TRUE, sep = ",", quote = "", stringsAsFactors = FALSE)
#... Relabel column names
colnames(Crimes2015) <-  c("Court","Charge")
colnames(Crimes2014) <-  c("Court","Charge")
colnames(Crimes2013) <-  c("Court","Charge")
colnames(Crimes2012) <-  c("Court","Charge")
colnames(Crimes2011) <-  c("Court","Charge")
#...Add Year column
Crimes2015 <- data.frame(Crimes2015,"Year"=2015)
Crimes2014 <- data.frame(Crimes2014,"Year"=2014)
Crimes2013 <- data.frame(Crimes2013,"Year"=2013)
Crimes2012 <- data.frame(Crimes2012,"Year"=2012)
Crimes2011 <- data.frame(Crimes2011,"Year"=2011)
#...One ring to bind them...
Crimes <- (rbind(Crimes2011,Crimes2012,Crimes2013,Crimes2014,Crimes2015))
setwd("C:/JoyGilfilen/Bookings")
write.csv(Crimes, "Crimes.csv")

# regularize ASSAULT terminology so  that all ASSAULT labels are one of the character vectors: "ASSAULT 1", "ASSAULT 2", "ASSAULT 3", "ASSAULT 4"
Crimes$Charge <- gsub("1ST","1", Crimes$Charge,fixed=TRUE)
Crimes$Charge <- gsub("1st","1", Crimes$Charge,fixed=TRUE)
Crimes$Charge <- gsub("2ND","2", Crimes$Charge,fixed=TRUE)
Crimes$Charge <- gsub("2nd","2", Crimes$Charge,fixed=TRUE)
Crimes$Charge <- gsub("3RD","3", Crimes$Charge,fixed=TRUE)
Crimes$Charge <- gsub("3rd","3", Crimes$Charge,fixed=TRUE)
Crimes$Charge <- gsub("4TH","4", Crimes$Charge,fixed=TRUE)
Crimes$Charge <- gsub("4th","4", Crimes$Charge,fixed=TRUE)

Crimes$Charge <- gsub("ASSLT","ASSAULT", Crimes$Charge,fixed=TRUE)
summarise(subset(Crimes, grepl('ASSLT',Charge)),length(Charge))
Crimes$Charge <- gsub("ASLT","ASSAULT", Crimes$Charge,fixed=TRUE)
summarise(subset(Crimes, grepl('ASLT',Charge)),length(Charge))

Crimes$Charge <- gsub("ASSAULT1","ASSAULT 1", Crimes$Charge,fixed=TRUE)
summarise(subset(Crimes, grepl('ASSAULT1',Charge)),length(Charge))
Crimes$Charge <- gsub("ASSAULT2","ASSAULT 2", Crimes$Charge,fixed=TRUE)
summarise(subset(Crimes, grepl('ASSAULT2',Charge)),length(Charge))
Crimes$Charge <- gsub("ASSAULT3","ASSAULT 3", Crimes$Charge,fixed=TRUE)
summarise(subset(Crimes, grepl('ASSAULT3',Charge)),length(Charge))
Crimes$Charge <- gsub("ASSAULT4","ASSAULT 4", Crimes$Charge,fixed=TRUE)
summarise(subset(Crimes, grepl('ASSAULT4',Charge)),length(Charge))

Crimes$Charge <- gsub("ASSAULT 1ST","ASSAULT 1", Crimes$Charge,fixed=TRUE)
summarise(subset(Crimes, grepl('ASSAULT 1ST',Charge)),length(Charge))
Crimes$Charge <- gsub("ASSAULT 1st","ASSAULT 1", Crimes$Charge,fixed=TRUE)
summarise(subset(Crimes, grepl('ASSAULT 1st',Charge)),length(Charge))
Crimes$Charge <- gsub("ASSAULT 2ND","ASSAULT 2", Crimes$Charge,fixed=TRUE)
summarise(subset(Crimes, grepl('ASSAULT 2ND',Charge)),length(Charge))
Crimes$Charge <- gsub("ASSAULT 2nd","ASSAULT 2", Crimes$Charge,fixed=TRUE)
summarise(subset(Crimes, grepl('ASSAULT 2nd',Charge)),length(Charge))
Crimes$Charge <- gsub("ASSAULT 3RD","ASSAULT 3", Crimes$Charge,fixed=TRUE)
summarise(subset(Crimes, grepl('ASSAULT 3RD',Charge)),length(Charge))
Crimes$Charge <- gsub("ASSAULT 3rd","ASSAULT 3", Crimes$Charge,fixed=TRUE)
summarise(subset(Crimes, grepl('ASSAULT 3rd',Charge)),length(Charge))
Crimes$Charge <- gsub("ASSAULT 4TH","ASSAULT 4", Crimes$Charge,fixed=TRUE)
summarise(subset(Crimes, grepl('ASSAULT 4TH',Charge)),length(Charge))
Crimes$Charge <- gsub("ASSAULT 4th","ASSAULT 4", Crimes$Charge,fixed=TRUE)
summarise(subset(Crimes, grepl('ASSAULT 4th',Charge)),length(Charge))

# Total all crimes and sort by count.
nrow(Crimes)
count(Crimes,Charge,sort=TRUE)
All <- count(Crimes,Charge,sort=TRUE)
All
with(data.frame(All[2:20,]),barplot(n,names.arg=Charge,las=2,cex.names=.50))

# Let's search for and categorize some crime
MURDER_ <- summarise(subset(Crimes, grepl('MURDER',Charge)),length(Charge))
HOMICIDE_ <- summarise(subset(Crimes, grepl('HOMICIDE',Charge)),length(Charge))
MANSLAUGHTER_ <- summarise(subset(Crimes, grepl('MANSLAUGHTER',Charge)),length(Charge))
RAPE_ <- summarise(subset(Crimes, grepl('RAPE',Charge)),length(Charge))
ASSAULT1_ <- summarise(subset(Crimes, grepl('ASSAULT 1',Charge)),length(Charge))
ASSAULT2_ <- summarise(subset(Crimes, grepl('ASSAULT 2',Charge)),length(Charge))
ASSAULT3_ <- summarise(subset(Crimes, grepl('ASSAULT 3',Charge)),length(Charge))
ASSAULT4_ <- summarise(subset(Crimes, grepl('ASSAULT 4',Charge)),length(Charge))

# This sample could be considered all violent crime
Sample <- data.frame(
rbind(
cbind("Cat"="MURDER","Amount"=MURDER_),
cbind("Cat"="HOMICIDE","Amount"=HOMICIDE_),
cbind("Cat"="MANSLAUGHTER","Amount"=MANSLAUGHTER_),
cbind("Cat"="RAPE","Amount"=RAPE_),
cbind("Cat"="ASSAULT1","Amount"=ASSAULT1_),
cbind("Cat"="ASSAULT2","Amount"=ASSAULT2_)
)
)
colnames(Sample) <- c("Category", "Charged")
arrange(Sample,desc(Charged))

# This sample are the four categories of Assault ...
Sample <- data.frame(
rbind(
cbind("Cat"="ASSAULT1","Amount"=ASSAULT1_),
cbind("Cat"="ASSAULT2","Amount"=ASSAULT2_),
cbind("Cat"="ASSAULT3","Amount"=ASSAULT3_),
cbind("Cat"="ASSAULT4","Amount"=ASSAULT4_)
)
)
colnames(Sample) <- c("Category", "Charged")
Sample <- data.frame(cbind(Sample,"PCT"=format(Sample$Charged/(sum(Sample$Charged) / 100),nsample=2,digits=3)))
arrange(Sample,desc(Charged))

# Arbitrary terms for most common crimes
DUI_ <- summarise(subset(Crimes, grepl('DUI',Charge)),length(Charge))
ASSAULT_ <- summarise(subset(Crimes, grepl('ASSAULT',Charge)),length(Charge))
DWLS_ <- summarise(subset(Crimes, grepl('DWLS',Charge)),length(Charge))
THEFT_ <- summarise(subset(Crimes, grepl('THEFT',Charge)),length(Charge))
CONT_ <- summarise(subset(Crimes, grepl('CONT',Charge)),length(Charge))
FTA_ <- summarise(subset(Crimes, grepl('FTA',Charge)),length(Charge))
DOC_ <- summarise(subset(Crimes, grepl('DOC',Charge)),length(Charge))
VIOL_ <- summarise(subset(Crimes, grepl('VIOL',Charge)),length(Charge))
ORDER_ <-summarise(subset(Crimes, grepl('ORDER',Charge)),length(Charge))
DRUG_ <-summarise(subset(Crimes, grepl('DRUG',Charge)),length(Charge))
BURGLARY_ <-summarise(subset(Crimes, grepl('BURGLARY',Charge)),length(Charge))
ROBBERY_ <-summarise(subset(Crimes, grepl('ROBBERY',Charge)),length(Charge))

# Build the sample
Sample <- data.frame(
rbind(
cbind("Cat"="DUI","Amount"=DUI_),
cbind("Cat"="ASSAULT","Amount"=ASSAULT_),
cbind("Cat"="DWLS","Amount"=DWLS_),
cbind("Cat"="THEFT","Amount"=THEFT_),
cbind("Cat"="CONT","Amount"=CONT_),
cbind("Cat"="FTA","Amount"=FTA_),
cbind("Cat"="DOC","Amount"=DOC_),
cbind("Cat"="VIOL","Amount"=VIOL_),
cbind("Cat"="ORDER","Amount"=ORDER_),
cbind("Cat"="CONT","Amount"=CONT_),
cbind("Cat"="DRUG","Amount"=DRUG_),
cbind("Cat"="BURGLARY","Amount"=VIOL_),
cbind("Cat"="ROBBERY","Amount"=ORDER_)
)
)
colnames(Sample) <- c("Category", "Charged")
arrange(Sample,desc(Charged))


# ... Save for later
# xDUI <- function(x) {summarise(filter(Crimes, grepl("DUI",Charge) & Year == x ),length(Year))}
# xASSAULT <- function(x) {summarise(subset(Crimes, grepl("ASSAULT",Charge) & Year == x ),length(Year))}
# xDWLS <- function(x) {summarise(subset(Crimes, grepl("DWLS",Charge) & Year == x ),length(Year))}
# xVIOL <- function(x) {summarise(subset(Crimes, grepl("VIOL",Charge) & Year == x ),length(Year))}

# ... Save for later
# DUI <- as.matrix(sapply(Years,xDUI));rownames(DUI) <- print(Years);DUI <- data.frame(DUI)
# ASSAULT <- as.matrix(sapply(Years,xASSAULT));rownames(ASSAULT) <- print(Years);ASSAULT <- data.frame(ASSAULT)
# DWLS <- as.matrix(sapply(Years,xDWLS));rownames(DWLS) <- print(Years);DWLS <- data.frame(DWLS)
# VIOL <- as.matrix(sapply(Years,xVIOL));rownames(VIOL) <- print(Years);VIOL <- data.frame(VIOL)

# ... Create Functions (x for grepl Charge total, xy for grepl Charged with FTA)
xDUI <- function(x) {nrow(subset(Crimes, grepl("DUI",Charge) & Year == x,select=Year))}
xyDUI <- function(x) {nrow(subset(subset(Crimes, grepl("DUI",Charge) & Year == x),grepl("FTA",Charge),select=Year))}
xASSAULT <- function(x) {nrow(subset(Crimes, grepl("ASSAULT",Charge) & Year == x,select=Year))}
xyASSAULT <- function(x) {nrow(subset(subset(Crimes, grepl("ASSAULT",Charge) & Year == x),grepl("FTA",Charge),select=Year))}
xDWLS <- function(x) {nrow(subset(Crimes, grepl("DWLS",Charge) & Year == x,select=Year))}
xyDWLS <- function(x) {nrow(subset(subset(Crimes, grepl("DWLS",Charge) & Year == x),grepl("FTA",Charge),select=Year))}
xVIOL <- function(x) {nrow(subset(Crimes, grepl("VIOL",Charge) & Year == x,select=Year))}
xyVIOL <- function(x) {nrow(subset(subset(Crimes, grepl("VIOL",Charge) & Year == x),grepl("FTA",Charge),select=Year))}

# ... Run Function ... Store Result
DUI <- as.data.frame(cbind("Year"=Years,"DUI"=sapply(Years,xDUI)))
DUI_FTA <- as.data.frame(cbind("Year"=Years,"DUI_FTA"=sapply(Years,xyDUI)))
ASSAULT <- as.data.frame(cbind("Year"=Years,"ASSAULT"=sapply(Years,xASSAULT)))
ASSAULT_FTA <- as.data.frame(cbind("Year"=Years,"ASSAULT_FTA"=sapply(Years,xyASSAULT)))
DWLS <- as.data.frame(cbind("Year"=Years,"DWLS"=sapply(Years,xDWLS)))
DWLS_FTA <- as.data.frame(cbind("Year"=Years,"DWLS_FTA"=sapply(Years,xyDWLS)))
VIOL <- as.data.frame(cbind("Year"=Years,"VIOL"=sapply(Years,xVIOL)))
VIOL_FTA <- as.data.frame(cbind("Year"=Years,"VIOL_FTA"=sapply(Years,xyVIOL)))

# .... Linking DUI DWLS
Alla <- merge(merge(DUI,DWLS,by.all=Year),merge(ASSAULT,VIOL,by.all=Year),by.all=Year)
Allb <- data.frame("Year"=Years,"Total"=rbind(nrow(Crimes2011),nrow(Crimes2012),nrow(Crimes2013),nrow(Crimes2014),nrow(Crimes2015)))
Allc <- merge(Alla,Allb,by.all=Year)
Alld <- cbind(Allc,"PCT"=format(as.numeric((rowSums(Allc[2:5]) / Allc$Total) * 100),digits=2))
Alld
with(Alld,cor(DUI,DWLS))


# Linking assault 4 with various NCO VIOL: Lines 203 - 255!!
x4ASSAULT <- function(x) {nrow(subset(Crimes, grepl("ASSAULT 4",Charge) & Year == x,select=Year))}
xy4ASSAULT <- function(x) {nrow(subset(subset(Crimes, grepl("ASSAULT 4",Charge) & Year == x),grepl("FTA",Charge),select=Year))}
xNCOVIOL <- function(x) {nrow(subset(subset(Crimes, grepl("VIOL",Charge) & Year == x),grepl("NCO",Charge),select=Year))}
xyNCOVIOL <- function(x) {nrow(subset(subset(subset(Crimes, grepl("VIOL",Charge) & Year == x),grepl("NCO",Charge)),grepl("FTA",Charge),select=Year))}
xNoContactOrderVIOL <- function(x) {nrow(subset(subset(Crimes, grepl("VIOL",Charge) & Year == x),grepl("NO CONTACT ORDER",Charge),select=Year))}
xyNoContactOrderVIOL <- function(x) {nrow(subset(subset(subset(Crimes, grepl("VIOL",Charge) & Year == x),grepl("NO CONTACT ORDER",Charge)),grepl("FTA",Charge),select=Year))}
xProtectionOrderVIOL <- function(x) {nrow(subset(subset(Crimes, grepl("VIOL",Charge) & Year == x),grepl("PROTECTION ORDER",Charge),select=Year))}
xyProtectionOrderVIOL <- function(x) {nrow(subset(subset(subset(Crimes, grepl("VIOL",Charge) & Year == x),grepl("PROTECTION ORDER",Charge)),grepl("FTA",Charge),select=Year))}

ASSAULT4 <- as.data.frame(cbind("Year"=Years,"ASSAULT4"=sapply(Years,x4ASSAULT)))
ASSAULT4_FTA <- as.data.frame(cbind("Year"=Years,"ASSAULT4_FTA"=sapply(Years,xy4ASSAULT)))
VIOLNCO <- as.data.frame(cbind("Year"=Years,"VIOLNCO"=sapply(Years,xNCOVIOL)))
VIOLNCO_FTA <- as.data.frame(cbind("Year"=Years,"VIOLNCO_FTA"=sapply(Years,xyNCOVIOL)))
VIOLNoContactOrder <- as.data.frame(cbind("Year"=Years,"VIOLNoContactOrder"=sapply(Years,xNoContactOrderVIOL)))
VIOLNoContactOrder_FTA <- as.data.frame(cbind("Year"=Years,"VIOLNoContactOrder_FTA"=sapply(Years,xyNoContactOrderVIOL)))
VIOLProtectionOrder <- as.data.frame(cbind("Year"=Years,"VIOLProtectionOrder"=sapply(Years,xProtectionOrderVIOL)))
VIOLProtectionOrder_FTA <- as.data.frame(cbind("Year"=Years,"VIOLProtectionOrder_FTA"=sapply(Years,xyProtectionOrderVIOL)))

Alle <- merge(merge(ASSAULT4,ASSAULT4_FTA,by.all=Year),merge(VIOLNCO,VIOLNCO_FTA,by.all=Year),by.all=Year)
Allf <- data.frame("Year"=Years,"Total"=rbind(nrow(Crimes2011),nrow(Crimes2012),nrow(Crimes2013),nrow(Crimes2014),nrow(Crimes2015)))
Allg <- merge(Alle,Allf,by.all=Year)
Allh <- cbind(Allg,"PCT"=format(as.numeric((rowSums(Allg[2:5]) / Allg$Total) * 100),digits=2))
Allh

Alli <- merge(merge(ASSAULT4,ASSAULT4_FTA,by.all=Year),merge(VIOLNoContactOrder,VIOLNoContactOrder_FTA,by.all=Year),by.all=Year)
Allj <- data.frame("Year"=Years,"Total"=rbind(nrow(Crimes2011),nrow(Crimes2012),nrow(Crimes2013),nrow(Crimes2014),nrow(Crimes2015)))
Allk <- merge(Alli,Allj,by.all=Year)
Alll <- cbind(Allk,"PCT"=format(as.numeric((rowSums(Allg[2:5]) / Allk$Total) * 100),digits=2))
Alll

Alln <- merge(merge(ASSAULT4,ASSAULT4_FTA,by.all=Year),merge(VIOLProtectionOrder,VIOLProtectionOrder_FTA,by.all=Year),by.all=Year)
Allo <- data.frame("Year"=Years,"Total"=rbind(nrow(Crimes2011),nrow(Crimes2012),nrow(Crimes2013),nrow(Crimes2014),nrow(Crimes2015)))
Allp <- merge(Alln,Allo,by.all=Year)
Allq <- cbind(Allp,"PCT"=format(as.numeric((rowSums(Allp[2:5]) / Allp$Total) * 100),digits=2))
Allq

Allz <- merge(merge(ASSAULT4,VIOLNCO,by.all=Year),merge(VIOLNoContactOrder,VIOLProtectionOrder,by.all=Year),by.all=Year)
Allz1 <- data.frame("Year"=Years,"Total"=rbind(nrow(Crimes2011),nrow(Crimes2012),nrow(Crimes2013),nrow(Crimes2014),nrow(Crimes2015)))
Allz2 <- merge(Allz,Allz1,by.all=Year)
Allz3 <- cbind(Allz2,"PCT"=format(as.numeric((rowSums(Allz2[2:5]) / Allz2$Total) * 100),digits=2))
Allz4 <- data.frame(with(Allz3,cbind(Allz3,"AllNCO"=(VIOLNCO + VIOLNoContactOrder + VIOLProtectionOrder))))
with(Allz4,cor(AllNCO,ASSAULT4))

#...Charts for Correlations Includes FTA bookings
with(Allz4,plot(AllNCO ~ Year,col="red",type="b",ylim=c(0,1000),ylab="ASSAULT4 vs. types of  'No Contact Orders'. Includes FTA Bookings"))
with(Allz4,lines(ASSAULT4 ~ Year,col="blue",type="b",ylim=c(0,1000),ylab=""))
mtext("ASSAULT 4 in red. Cumulative VIOLATIONS for 'NCO', 'NO CONTACT ORDER', 'PROTECTION ORDER' in blue.",line=2)
mtext("Note: 2015 figures are for six months.",line=1)

with(Alld,plot(DUI ~ Year,col="red",type="b",ylim=c(500,2000),ylab="'DUI vs. DWLS' Includes FTA Bookings"))
with(Alld,lines(DWLS ~ Year,col="blue",type="b",ylim=c(500,2000),ylab=""))
mtext("DUI 4 in red. DWLS in blue.",line=2)
mtext("Note: 2015 figures are for six months.",line=1)

#...Correlations Includes FTA bookings
with(Alld,cor(DUI,DWLS))
with(Allh,cor(ASSAULT4,VIOLNCO))
with(Alll,cor(ASSAULT4,VIOLNoContactOrder))
with(Allq,cor(ASSAULT4,VIOLProtectionOrder))

cor(Alle$ASSAULT4,(Allh$VIOLNCO + Alll$VIOLProtectionOrder + Allq$VIOLProtectionOrder))

# More Charts
#... Lattice Charts 
with(subset(count(Crimes,Charge,sort=TRUE),grepl("DUI",Charge))[1:25,],barplot(n,names.arg=Charge,las=2,cex.names=.5))
with(subset(count(Crimes,Charge,sort=TRUE),grepl("DWLS",Charge))[1:25,],barplot(n,names.arg=Charge,las=2,cex.names=.5))
with(subset(count(Crimes,Charge,sort=TRUE),grepl("ASSAULT",Charge))[1:25,],barplot(n,names.arg=Charge,las=2,cex.names=.5))
with(subset(count(Crimes,Charge,sort=TRUE),grepl("VIOL",Charge))[1:25,],barplot(n,names.arg=Charge,las=2,cex.names=.5))


#Stuff to create table of FTA and non FTA Charges
DUIz <- data.frame(cbind("Year"=Years,"DUI"=DUI[,2],"DUI-not-FTA"=(DUI[,2] - DUI_FTA[,2])))
ASSAULTz <- data.frame(cbind("Year"=Years,"ASSAULT"=ASSAULT[,2],"ASSAULT-not-FTA"=(ASSAULT[,2] - ASSAULT_FTA[,2])))
DWLSz <- data.frame(cbind("Year"=Years,"DWLS"=DWLS[,2],"DWLS-not-FTA"=(DWLS[,2] - DWLS_FTA[,2])))
VIOLz <- data.frame(cbind("Year"=Years,"VIOL"=VIOL[,2],"VIOL-not-FTA"=(VIOL[,2] - VIOL_FTA[,2])))
DUI.DWLS <- merge(DUIz,DWLSz,by.all=Year)
ASSAULT.VIOL <- merge(ASSAULTz,VIOLz,by.all=Year)

DUI.DWLS
ASSAULT.VIOL

# DUI.DWLS without FTA and also Projects 2015
with(DUI.DWLS,plot(DUI.not.FTA ~ Year,type="l",col="red",ylab="",ylim=c(500,1500))) ; with(DUI.DWLS,lines(DWLS.not.FTA ~ Year,type="l",col="blue",ylab="",ylim=c(500,1500)))
mtext("DUI.not.FTA (red);DWLS.not.FTA (blue)")
P_DUI.DWLS <- DUI.DWLS # Edit P_DUI.DWLS to project 2015
with(P_DUI.DWLS,plot(DUI.not.FTA ~ Year,type="l",col="red",ylab="",ylim=c(500,1500))) ; with(P_DUI.DWLS,lines(DWLS.not.FTA ~ Year,type="l",col="blue",ylab="",ylim=c(500,1500)))
mtext("DUI.not.FTA (red);DWLS.not.FTA (blue) with 2015 Projected")
# ASSAULT.VIOL without FTA and also Projects 2015
with(ASSAULT.VIOL,plot(ASSAULT.not.FTA ~ Year,type="l",col="red",ylab="",ylim=c(300,1300))) ; with(ASSAULT.VIOL,lines(VIOL.not.FTA ~ Year,type="l",col="blue",ylab="",ylim=c(300,1300)))
mtext("ASSAULT.not.FTA (red);VIOL.not.FTA (blue)")
P_ASSAULT.VIOL <- ASSAULT.VIOL # Edit P_ASSAULT.VIOL to project 2015
with(P_ASSAULT.VIOL,plot(ASSAULT.not.FTA ~ Year,type="l",col="red",ylab="",ylim=c(300,1300))) ; with(P_ASSAULT.VIOL,lines(VIOL.not.FTA ~ Year,type="l",col="blue",ylab="",ylim=c(300,1300)))
mtext("ASSAULT.not.FTA (red);VIOL.not.FTA (blue)")

No comments:

Post a Comment