I want to hide a tab when a user selects a certain option in a dropdown. I've put the code inside:
output$text1 <- function() {
........
# Hide rate ratio tab if a indicator is for medians
if (grepl("MEDIAN", toupper(input$selected.indicator), fixed=TRUE)){hideTab(inputId="tabselected",target=2)}
else {showTab(inputId="tabselected",target=2)}
.......
}
the ui:
tabsetPanel(
tabPanel("Prevalence / mean", value=1, DT::dataTableOutput("prevtab")),
tabPanel("Subgroups comparison", value=2, DT::dataTableOutput("comptab")),
id ="tabselected"
),
What am I doing wrong here? Thanks!
Update: rewritten more logically now but still not hiding tab:
observeEvent(input$selected.indicator, {if (grepl("MEDIAN", toupper(input$selected.indicator), fixed=TRUE))
{hideTab(inputId="tabselected",target=2)}
else {showTab(inputId="tabselected",target=2)}
})