-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp_server.R
32 lines (28 loc) · 1.01 KB
/
app_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
library(shiny)
library(plotly)
library(ggplot2)
####
# Write your section in your own R file so we can source() it in and
# avoid having to deal with merge conflicts.
source("shiny_pages/police_output.R")
source("shiny_pages/violence_output.R")
source("shiny_pages/victim_output.R")
server <- function(input, output) {
# template:
# output$<id name> <- <function returning graphic from other file>
# exercise 19-7 exercise solution has example
# Outputs for police page
police_df <- read.csv("data/police_killings.csv", stringsAsFactors = FALSE)
output$police_chart <- renderPlotly({
return(build_police(police_df, input$policevar))
})
violence_df <- read.csv("data/gun_violence_abridged.csv",
stringsAsFactors = FALSE)
output$map <- renderLeaflet({
build_violence(violence_df, input$state_search)
})
victim_df <- read.csv("data/firearm_homicide.csv", stringsAsFactors = FALSE)
output$victim_pie_chart <- renderPlotly({
return(vitctim_pie(victim_df, input$charactor))
})
}