[英]R Shiny - Conditional panel within conditional panel
I am wondering if it is possible to have a conditional panel within another conditional panel. 我想知道是否有可能在另一个条件面板中有一个条件面板。
For example if I have a drop down list with two options: 1 and 2 例如,如果我有一个包含两个选项的下拉列表:1和2
selecting 1 will display one set of options and selecting 2 will display a different set of options. 选择1将显示一组选项,选择2将显示一组不同的选项。
But is it possible to have a conditional panel nested within these conditional panel so that I could have another drop down list within the inputs for option 1. 但是有可能将条件面板嵌套在这些条件面板中,这样我就可以在选项1的输入中有另一个下拉列表。
Here is some code for an example of what I am trying to do but this does not work 下面是一些我想要做的例子的代码,但这不起作用
selectInput("n", label = h3("Select Option"),
choices = list("1" = 1, "2" = 2),
selected = 1),
#1
conditionalPanel(
condition = "input.n == '1'",
titlePanel("1 Options"),
selectInput("b", label = h4("Select Option"),
choices = list("A" = 1, "B" = 2),
conditionalPanel(
condition = "input.b == '1'",
titlePanel("1 Options")
),
conditionalPanel(
condition = "input.b == '2'",
titlePanel("2 Options")
),
)),
Yes, you can easily nest conditional panels, more or less as you were attempting to. 是的,您可以轻松地嵌套条件面板,或多或少地尝试。 In your code you just had a few misplaced parentheses and extra commas. 在你的代码中,你只是有一些错位的括号和额外的逗号。 Here is a working app that does what you're asking, I think: 我认为这是一个可以满足你要求的工作应用程序:
ui <- fluidPage(
selectInput("n", label = h3("Select Option"),
choices = list("1" = 1, "2" = 2),
selected = 1),
conditionalPanel(
condition = "input.n == '1'",
titlePanel("1 Options"),
selectInput("b", label = h4("Select Option"),
choices = list("A" = 1, "B" = 2)),
conditionalPanel(
condition = "input.b == '1'",
titlePanel("1 Options")
),
conditionalPanel(
condition = "input.b == '2'",
titlePanel("2 Options")
)
)
)
server <- function(input, output){}
shinyApp(ui, server)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.