I would like to show the condition only when values are chosen for the three radioButtons
, no matter the options. As it is, I choose an option just and this condition already appears, but that's not what I want. And I left it as '2'
em "input.radio1 == '2'
, but just as an example, the idea is that it is valid for any chosen value.
Executable code below:
library(shiny)
library(shinythemes)
ui <- bootstrapPage(
navbarPage(theme = shinytheme("flatly"), collapsible = TRUE,
"Cl",
tabPanel("Solution",
sidebarLayout(
sidebarPanel(
radioButtons("radio1", label = h3("Choose 1"),
choices = list("Option1" = 2, "Option2" = 3, "Option3" = 4),
selected = ""),
radioButtons("radio2", label = h3("Choose 2"),
choices = list("Option4" = 2, "3 clusters" = 3, "Option5" = 4),
selected = ""),
radioButtons("radio3", label = h3("Choose 3"),
choices = list("Option6" = 2, "Option1" = 3, "Option8" = 4),
selected = ""),
conditionalPanel(
condition = "input.radio1 == '2'|| input.radio2 == '2'|| input.radio3 == '2'",
tags$hr(style="border-color: black;"),
tags$p(h3("Are you satisfied with this solution?")),
radioButtons( "satisfaction","", choices = list("Yes" = 1,"Not " = 2),selected = 1))
),
mainPanel(
tabsetPanel(
)))
)))
server <- function(input, output, session) {
}
shinyApp(ui = ui, server = server)
Update
From what I've seen you have to use &&
instead of ||
in condition
. Now I just need to adjust the issue that it can be any choice of radiobutton1
, radiobutton2
and radiobutton3
, not just option 2
.
CodePudding user response:
With this condition = "input.radio1 && input.radio2 && input.radio3"
, the conditionalPanel should appear only if the user has selected a choice for all 3 radio buttons.