-
Notifications
You must be signed in to change notification settings - Fork 3
/
app.R
74 lines (58 loc) · 2.25 KB
/
app.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# weekly data
df<- readr::read_csv('master_2022.csv') |>
dplyr::arrange(week, date_pulled)
# UI creation ----
ui<- fluidPage(titlePanel('Weekly Legs'),
shiny::sidebarLayout(
shiny::sidebarPanel(
width= 3,
shiny::h1('Pick a Week'),
shiny::selectInput(
inputId = "week_select",
label = "Select a Week",
choices = unique(df$week),
selected = 1),
shiny::h2('Pick a Game'),
shiny::selectInput(
inputId = "game_select",
label = "Select a Game",
choices = NULL)),
shiny::mainPanel(
shiny::tabsetPanel(
shiny::tabPanel(
plotly::plotlyOutput('gameplot', width = 800, height = 500),
div(style = "height:50px"),
plotly::plotlyOutput('ou_plot', width = 800, height = 500),
div(style = "height:50px"))
)
)
)
)
# build app ----
server<- function(input, output){
week_select <- reactive({
dplyr::filter(df, week == input$week_select)
})
observeEvent(week_select(), {
choices <- unique(week_select()$matchup)
updateSelectInput(inputId = "game_select", choices = choices)
})
game <- reactive({
shiny::req(input$game_select)
dplyr::filter(week_select(), matchup == input$game_select)
})
output$gameplot<- plotly::renderPlotly({
req(input$game_select)
week_select() |>
dplyr::filter(matchup == input$game_select) |>
oddsmaker::pick_share_plot()
})
output$ou_plot<- plotly::renderPlotly({
req(input$game_select)
week_select() |>
dplyr::filter(matchup == input$game_select) |>
oddsmaker::ou_share_plot()
})
}
# run the app ----
shiny::shinyApp(ui= ui, server= server)