Hi,
I'm sorry it didn't work out as you liked. I think your approach is a bit convoluted as the conditional panel is made for something else than feeding into a switch function (which is an R function and is not going to work in the UI).
The only way I see it is creating two conditional panels, each with their own input, and displaying it depending on the choice of items_list_selection. Still,you'll need the updateSelectInput if you want to update the choices of the lists themselves on the go...
Give this a try:
library("shiny")
ui <- fluidPage(
sidebarLayout(
sidebarPanel(
# the user can choose from two options within the radio buttons
radioButtons("items_list_selection", label = "select item list"
, choices = list("Items - Item number & name" = "Both", "Items - Item name only" = "Name"), selected = "Both")
, conditionalPanel(
condition = "output.items_list_selection == 'Both'"
, selectInput("itemsBoth", label = 'Select items'
# this is where I don't think I'm properly passing the value from output
, choices = c("Both_Choice1", "Both_Choice2", "Both_Choice3")
, multiple = TRUE)),
conditionalPanel(
condition = "output.items_list_selection == 'Name'"
, selectInput("itemsName", label = 'Select items'
# this is where I don't think I'm properly passing the value from output
, choices = c("Name_Choice1", "Name_Choice2")
, multiple = TRUE))
# action button so the user can submit for analysis based on their selected options
, actionButton("go", "Run", style = "color: white; background-color: #2759aa")
),
mainPanel()
)
)
server <- function(input, output){
output$items_list_selection <- reactive({
input$items_list_selection
})
outputOptions(output, "items_list_selection", suspendWhenHidden = FALSE)
}
shinyApp(ui, server)
It has the same result, and I'd be surprised if it were faster than my first suggestion, but since I still don't get your issue 100% it might help ...
Grtz
PJ