I'm building a shiny app which displays a table based on user selections. I have a table called 'stat' and it is of the form
Team Season wins loss draws
Arsenal 1992-93 18 12 14
Arsenal 1993-94 21 10 7
Liverpool 1992-93 22 6 12
Liverpool 1993-94 19 13 10
All All 0 0 0
I need to filter the data based on the team and season selected. The table should display all season's data when 'All' is selected for season and vice versa for team.
I had tried some of the code below but it's not working as expected.
#UI part
selectInput("club", "Select Club", choices = stat$Team),
selectInput("season", "Select Season", choices =
stat$Season)
#server part
server <- output$statdata <- renderTable({
teamfilter <- subset(stat, (stat$Team == input$club) &
(stat$Season==input$season))
})
observe({
if("Select All" %in% input$club)
selected_choices = stat$Team[-1]
else
selected_choices = input$club
updateSelectInput(session, "club", selected = selected_choices)
})
Can some suggest me a correct code or tell me if any changes are required to make the code working.