-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmap1.r
32 lines (23 loc) · 820 Bytes
/
map1.r
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
library(tidyverse)
library(ggmap)
library(zipcode)
crime1217 <- read_csv("~/RProjects/crime/Chicago_Crimes_2012_to_2017.csv")
crime1217 <- crime1217 %>%
mutate(BlockName = substring(Block, 8)) %>%
blocks <- crime1217 %>%
group_by(BlockName) %>%
summarise(
count = n()
) %>%
arrange(desc(count)) %>%
mutate(BlockName = factor(BlockName, levels = BlockName))
top50 <- ggplot(head(blocks,50)) +
geom_col(aes(x=BlockName, y = count)) +
coord_flip()
ggplot(crime1217) +
geom_histogram(aes(x=BlockName), stat = "count") +
coord_flip()
map<-get_map(location='chicago', zoom=13, maptype = "terrain",
source='google',color='color')
ggmap(map) +
geom_jitter(data=crime1217, mapping=aes(x=Longitude, y=Latitude, colour=`Primary Type`), alpha = 0.3)