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)}
.......
}
I think the problem is that you are using numeric values for the "value" and "target" parameter. Use strings instead - as least in the hideTab/showTab calls. Shiny will change the "value" values to strings in the HTML. You can verify this in the DOM explorer in the browser.
Yes, as mentioned by @stkrog using String type for value parameter of tabPanel works. Please check the below example, the "Subgroups comparison" tab is hidden only when "median" choice is selected and an observer can be used to perform the action at Server.