-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.R
52 lines (38 loc) · 1.45 KB
/
server.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# This is the server logic for a Shiny web application.
# You can find out more about building applications with Shiny here:
#
# http://shiny.rstudio.com
#
library(shiny)
server <- function(input, output, session) {
output$plot1 <- renderPlot({
data <- filter(event.log,
TEXT_GENERAL_CODE == input$crime.type &
year %in% input$year) %>%
group_by(month,year) %>%
summarise(
monthly.count = sum(event.count)
)
ggplot(data,
aes(x = month, y = monthly.count, color = factor(year))) +
stat_smooth(se = F) + geom_point() +
scale_color_brewer(palette="Set1",
name = "Year") +
labs(title = paste('Philadelphia Crime Occurences:', input$crime.type),
x = "", y = "Occurrences") +
scale_x_continuous(breaks = 1:12, labels = month(1:12, label = T) ) +
fte_theme()
})
output$mymap <- renderLeaflet({
points <- filter(coordinates,
TEXT_GENERAL_CODE == input$crime.type.map &
year %in% input$year.map)
leaflet() %>%
addProviderTiles('CartoDB.Positron') %>%
setView(lng=-75.06048, lat=40.03566, zoom = 11) %>%
addCircleMarkers( data = points,
lat = ~POINT_Y, lng = ~POINT_X,
clusterOptions = markerClusterOptions()
)
})
}