我需要在我的界面中有多个标签,并且在每个标签中我都想使用conditionalPanel。正如您将在下面看到的可重现代码所示,conditionalPanel在第一个选项卡中工作,但在其他选项卡中不工作。
ui <- pageWithSidebar(
headerPanel("Hello !"),
sidebarPanel(
tabsetPanel(
tabPanel("a",
textInput(inputId = "A1", label = "1:", value = "A1"),
checkboxInput(inputId = "new_A2",
label = "Add another one",
value = FALSE),
conditionalPanel(
condition = "input.new_A2 == true",
textInput(inputId = "A2", label = "2:", value = "A2")
)),
tabPanel("b",
textInput(inputId = "B1", label = "1:", value = "C1"),
checkboxInput(inputId = "new_B2",
label = "Add another one",
value = FALSE),
conditionalPanel(
condition = "input.new_B2 == true",
textInput(inputId = "B2", label = "2:", value = "C2")
)
)
)
),
mainPanel()
)
server <- function(input,output){
}
runApp(list(ui=ui,server=server))
我知道有很多与conditionalPanel相关的问题,但我还没有找到答案。
提前感谢您,任何建议都非常感谢
答案 0 :(得分:7)
为您的tabset面板添加一个id,例如tabsetPanel(id="tabs"
,并在标签“b”聚焦时添加条件input.tabs == 'b'
例如,在您的第二个条件面板中,条件为:
condition = "input.tabs == 'b' & input.new_B2 == true"
答案 1 :(得分:0)
在条件面板中,为了检查checkboxinput的条件表达式,我们应该使用1而不是TRUE。