Load quarterly RMS files into memory
datq1 <- read.csv("smcf_rms/01012014_03312014.csv",header=TRUE)
datq2 <- read.csv("smcf_rms/04012014_06302014.csv",header=TRUE)
datq3 <- read.csv("smcf_rms/07012014_09302014.csv",header=TRUE)
datq4 <- read.csv("smcf_rms/10012014_12312014.csv",header=TRUE)
Reduce to essential fields, and merge into 1 dataset
keep_cols <- c("Incidentnumber","Incidenttype")
datq1 <- datq1[keep_cols]
datq2 <- datq2[keep_cols]
datq3 <- datq3[keep_cols]
datq4 <- datq4[keep_cols]
dat2014 <- rbind(datq1,datq2)
dat2014 <- rbind(dat2014,datq3)
dat2014 <- rbind(dat2014,datq4)
De-duplicate records, the result is 1 instance of each incident number Rename the columns
dat2014.unq <- unique(dat2014)
colnames(dat2014.unq) <- c("Incidentnumber","Type")
Load the look-up table of incident codes & categories Rename the columns
tbl.lookup <- read.csv("ref/r_incident_lookup.csv",header=TRUE)
colnames(tbl.lookup) <- c("Type","Category","Detail")
Join the tables by the Type field
tbl.join <- merge(tbl.lookup,dat2014.unq,by="Type")
attach(tbl.join)
category.counts <- data.frame(table(Category))
category.counts
## Category Freq
## 1 Cancelled 200
## 2 Duplicate Location 1
## 3 Emergency Assist 133
## 4 Emergency Rescue 47
## 5 False Alarm 1780
## 6 Fire 280
## 7 Hazmat 45
## 8 Medical 6139
## 9 Other (NEC) 6
## 10 Service 669
## 11 Unknown 0
## 12 Vehicle Accident 383