Crime Data in Seattle

西雅圖很美, 但是仍有罪犯作案, 那些地方是案件常發生的地方?

library(ggmap)
## Loading required package: ggplot2
download.file("http://www.sharpsightlabs.com/wp-content/uploads/2015/01/seattle_crime_2010_to_2014_REDUCED.txt.zip", destfile="seattle_crime_2010_to_2014_REDUCED.txt.zip")


unzip("seattle_crime_2010_to_2014_REDUCED.txt.zip")
seattle_crime<- read.csv("seattle_crime_2010_to_2014_REDUCED.txt")
map.seattle_city <- qmap("seattle", zoom = 11, source="stamen", maptype="toner",darken = c(.3,"#BBBBBB"))
## Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=seattle&zoom=11&size=640x640&scale=2&maptype=terrain&sensor=false
## Information from URL : http://maps.googleapis.com/maps/api/geocode/json?address=seattle&sensor=false
## Map from URL : http://tile.stamen.com/toner/11/326/714.png
## Map from URL : http://tile.stamen.com/toner/11/327/714.png
## Map from URL : http://tile.stamen.com/toner/11/328/714.png
## Map from URL : http://tile.stamen.com/toner/11/329/714.png
## Map from URL : http://tile.stamen.com/toner/11/326/715.png
## Map from URL : http://tile.stamen.com/toner/11/327/715.png
## Map from URL : http://tile.stamen.com/toner/11/328/715.png
## Map from URL : http://tile.stamen.com/toner/11/329/715.png
## Map from URL : http://tile.stamen.com/toner/11/326/716.png
## Map from URL : http://tile.stamen.com/toner/11/327/716.png
## Map from URL : http://tile.stamen.com/toner/11/328/716.png
## Map from URL : http://tile.stamen.com/toner/11/329/716.png
## Warning: `panel.margin` is deprecated. Please use `panel.spacing` property
## instead
map.seattle_city

map.seattle_city +geom_point(data=seattle_crime, alpha = I(1/50), colour="red", aes(x=Longitude, y=Latitude))
## Warning: Removed 819 rows containing missing values (geom_point).

#Assault Crime Data at Seattle in August, 2010-2014

西雅圖太多罪犯作案, 那些地方是八月份攻擊案件常發生的地方?

newdata <- seattle_crime[ which(seattle_crime$crime_category=='Assault' 
& seattle_crime$Month == '8'), ]


map.seattle_city +geom_point(data=newdata, alpha = I(1/5), colour="red", aes(x=Longitude, y=Latitude))
## Warning: Removed 5 rows containing missing values (geom_point).