mkedata takes care of much of the grunt work of acquiring and processing Milwaukee data. This puts you much closer to doing what you most care about: analyzing and visualizing Milwaukee data.

Exploring Milwaukee Crime Data

What's the citywide trend in homicides?

library(mkedata)
data("crimes.munged")
h <- subset(crimes.munged, OFFENSE1 == "HOMICIDE")
barplot(table(h$year))

Mapping Milwaukee Data

Let's look at where those homicides took place in 2015. First overall, then in and around the Avenues West Business Improvement District.

library(sp)
# mkeoutline <- to_nad27(mkeoutline)
h2015 <- subset(crimes.munged, OFFENSE1 == "HOMICIDE" & year == "2015")
plot(mkeoutline)
plot(h2015, col = "salmon", add = T)

# bids <- to_nad27(bids)
plot(subset(bids, Name == "Avenues West"))
plot(h2015, col = "salmon", add = T)

Using ggmap and a transformation of the coordinates to the web map standard projection (WGS84), we can plot these crimes on a basemap for context:

library(ggmap)
h.wgs84 <- to_wgs84(h2015) 
m <- data.frame(slot(h.wgs84, "coords"), slot(h.wgs84, "data"))
    names(m)[1:2] <- c("lon", "lat")
    qmplot(lon, lat, data = m, color = I("salmon"))


MatthewSchumwinger/mkedata documentation built on May 7, 2019, 4:34 p.m.