In the below application, when we select second element in the Group By filter (Say Country), a render UI is popped up with default as 'USA'. When the user selects second country (sat UK) and selects Gender in the Group By filter, the second filter now becomes only USA (not USA and UK) . Wanted to check if we can still keep USA and UK in the second filter?
ui <- fluidPage(
selectInput("groupby", "Group By", choices = c("Month","Country","Gender", "Site ID", "Treatment Arm"),multiple = TRUE,selected = c("Month")),
uiOutput("coun")
)
server <- function(input, output, session) {
observe({
if(length(input$groupby) > 1){
output$coun <- renderUI({selectInput("country", "Country",selected = "USA", choices = c("USA","UK","EUR"),multiple = TRUE)})
} else {
output$coun <- renderUI({})
}
})
}
shinyApp(ui, server)