Hi there! I want to do the following:
-
Have a selectInput field whose values change depending on a radiobutton.
-
Do something with the value selected in the selectInput
In the code below 1. seems to be working, but 2. only works for the "high" option (or whatever is the first conditionalPanel selectInput I have in my code).
library(shiny)
library(tidyverse)
ui <- fluidPage(
mainPanel(
radioButtons("thresholds", "Thresholds",
c("high", "low"), selected = "high"),
conditionalPanel(
condition = "input.thresholds == 'high'",
selectInput('test', 'test',
cars %>% filter(speed >= 14) %>% pull(speed),
multiple = TRUE, selectize = FALSE, width = 300, size = 20)),
conditionalPanel(
condition = "input.thresholds == 'low'",
selectInput('test', 'test',
cars %>% filter(speed < 14) %>% pull(speed),
multiple = TRUE, selectize = FALSE, width = 300, size = 20)),
verbatimTextOutput('out1')))
server <- function(input, output) {
output$out1 <- renderPrint(input$test)
}
shinyApp(ui = ui, server = server)
I hope my explanation is clear enough... and thanks for the help!