退房的帮助?updateTabsetPanel
,或?conditionalPanel
如果你决定去updateTabsetPanel
方法,您可以根据用户的输入有选择的选项卡的变化(直接从帮助中获取):
# in server.R
shinyServer(function(input, output, session) {
observe({
# TRUE if input$controller is even, FALSE otherwise.
x_even <- input$controller %% 2 == 0
# Change the selected tab.
# Note that the tabsetPanel must have been created with an 'id' argument
if (x_even) {
updateTabsetPanel(session, "inTabset", selected = "panel2")
} else {
updateTabsetPanel(session, "inTabset", selected = "panel1")
}
})
})
请注意使用session
对象和?observe
。
如果你决定去conditionalPanel
方法:
# in ui.R
selectInput("method", "Method", c("A", "B")),
conditionalPanel(
condition = "input.method == 'A'",
plotOutput(...) # or whatever input/output you want
),
conditionalPanel(
condition = "input.method == 'B'",
plotOutput(...) # or whatever input/output you want
)
我不相信conditionalPanel
工程,使有条件的标签,但。 (我可能错了)