I know there are already some questions regarding this topics but I am still struggling with my own project.
In my shiny there are three select input widgets with should be reactive to each other. Only combinations that make sense should be possible.
the Code is now update to use mtcars. some variables names are weird now but this should matter.
library(shiny)
ui <- fluidPage(
selectInput(inputId = "INseason", label = "Season", choices = c("ALL", sort(unique(mtcars$am), decreasing = TRUE)), selected = NULL),
selectInput(inputId = "INcategory", label = "Category", choices = c("ALL", sort(unique(mtcars$gear))), selected = NULL),
selectInput(inputId = "INteams", label = "Team", choices = c("ALL", sort(unique(mtcars$carb))), selected = NULL)
)
server <- function(input, output, session) {
rv <- reactiveValues()
rv$data <- mtcars
observe({
if(input$INseason != "ALL") {
rv$data <- filter(rv$data, am == input$INseason)
}
if(input$INcategory != "ALL") {
rv$data <- filter(rv$data, gear == input$INcategory)
}
if(input$INteams != "ALL") {
rv$data <- filter(rv$data, carb == input$INteams)
}
})
observe({
updateSelectInput(session, "INseason", choices = c("ALL", sort(unique(rv$data$am), decreasing = TRUE)))
updateSelectInput(session, "INcategory", choices = c("ALL", sort(unique(rv$data$gear))))
updateSelectInput(session, "INteams", choices = c("ALL", sort(unique(rv$data$carb))))
})
}
shinyApp(ui, server)
With this code i am not able to select something because "ALL" is already preselected.
Thank you for your help!
Best
Shot_Data.rds
or use open source data such asmtcars
– Pork Chop