Вы хотите использовать updateSelectInput
, а затем использовать observeEvent
, чтобы перехватывать при изменении значения фильтра.
library(shiny)
library(shinydashboard)
rm(list=ls())
#####/UI/####
header <- dashboardHeader()
sidebar <- dashboardSidebar()
body <- dashboardBody(
selectInput(inputId = "filter1", label = "Filter 1", selected = "ALL",
choices = c("ALL", "Bananas", "Apples", "Oranges")
),
selectInput(inputId = "filter2", label = "Filter 2", selected = "ALL",
choices = c("ALL", "Carrots", "Peas", "Celery")
)
)
ui <- dashboardPage(header, sidebar, body)
#####/SERVER/####
server <- function(session, input, output) {
observeEvent(input$filter2,{
if (input$filter2 != "ALL") {
updateSelectInput(session, "filter1", selected = "ALL")
}
})
observeEvent(input$filter1,{
if (input$filter1 != "ALL") {
updateSelectInput(session, "filter2", selected = "ALL")
}
})
}
shinyApp(ui, server)