I am trying to get an app in which user will choose from "Variables set no 1" and conditionally another set of variables will show up (e.g. if A and B chosen in set 1 then A1 in second set will show up) and if box ticked the input variables will show up. I have done it with checkboxGroupInput and then set of checkboxInput but would like to have the latter turn into another checkboxGroupInput for filtering. To do so the conditional panel (of if - else, although I tried it and its not working) needs to be allowed to create dynamically list of choices. Rudimentary version of the code is below.
library(shiny)
ui <- fluidPage(
fluidRow(column(4,
checkboxGroupInput("variables",
"Variables set 1",
choices = c("A", "B", "C", "D"),
selected = NULL)),
##########################################################
# How to change this section into checkboxGroupInput??????
##########################################################
column(8,
conditionalPanel(
condition='input.variables.indexOf("A") > -1 &
input.variables.indexOf("B") > -1',
checkboxInput(inputId = "a1", label = "A1", value = FALSE)),
conditionalPanel(
condition='input.variables.indexOf("B") > -1 &
input.variables.indexOf("D") > -1',
checkboxInput(inputId = "a2", label = "A2", value = FALSE)),
conditionalPanel(
condition='input.variables.indexOf("B") > -1 &
input.variables.indexOf("C") > -1 &
input.variables.indexOf("D") > -1',
checkboxInput(inputId = "a3", label = "A3", value = FALSE)))),
##########################################################
fluidRow(column(6,
conditionalPanel(
condition = "input.a1 == 1 || input.a2 == 1",
radioButtons(inputId = "A11",
label = "A blah",
choices = list("Bla" = 2, "Ble" = 3),
selected = 2)),
conditionalPanel(
condition = "input.a3 == 1",
sliderInput(inputId = "B11",
label = "B blah",
min = 1, max = 10, value = 5, step = 1)),
conditionalPanel(
condition = "input.a1 == 1 || input.a2 == 1 || input.a3 == 1",
sliderInput(inputId = "C11",
label = "C blah",
min = 1, max = 10, value = 5, step = 1))))
)
server <- function(input, output, session) {}
shinyApp(ui = ui, server = server)
Thank you in advance!
Aucun commentaire:
Enregistrer un commentaire