【发布时间】:2021-07-09 17:41:48
【问题描述】:
我需要为不同的标签显示不同的下拉/选择输入。
例如。如果选择了第一个选项卡,则显示带有值列表的 selectinput Tim,Bill,Jeff,... 如果选择了选项卡二,则显示带有值列表的 selectinput Cat、Dog、Squirrel、...
我在网上找到了以下脚本,但反之亦然(根据选择输入选择显示/隐藏选项卡面板 - 但我需要根据选项卡面板选择显示/隐藏选择输入)。
runApp(list(
ui = shinyUI(
fluidPage(
sidebarLayout(
sidebarPanel(
selectInput(
inputId = 'selected.indicator',
label = 'Select an option: ',
choices = c('mean', 'median', 'mode')
)
),
mainPanel(
tabsetPanel(
tabPanel("Prevalence / mean", value = 'meanTab', DT::dataTableOutput("prevtab")),
tabPanel("Subgroups comparison", value = 'medianTab', DT::dataTableOutput("comptab")),
id ="tabselected"
)
)
)
)
),
server = function(input, output, session) {
observe({
req(input$selected.indicator)
if (grepl("MEDIAN", toupper(input$selected.indicator), fixed = TRUE)) {
hideTab(inputId = "tabselected", target = 'medianTab')
}
else showTab(inputId = "tabselected", target = 'medianTab')
})
}
))
【问题讨论】:
标签: r shiny shinydashboard shinyapps shiny-reactivity