I want to use action buttons to navigate to differentes tabs of the sidebar menu in a shiny app, but when I click the button nothings happen.
Here is the code
header <- dashboardHeader(
title = "Button Test"
)
sidebar <- dashboardSidebar(
#sidebarmenu
sidebarMenu(id ="tabs",
menuItem("Introduction", tabName = "intro", icon = icon("edit") ),
menuItem("Data Input", tabName = "data", icon = icon("server")),
menuItem("Quality Contol", tabName = "qc", icon = icon("braille")
body <- dashboardBody(
#tabitems
tabItems(
##################Intro tab#################
tabItem(tabName = "intro",
h1("Introduction")),
tabItem(tabName = "data",
h1("data"),
actionButton("btn_switchtab", "Go to QC", class ="btn-info")),
tabItem(tabName = "qcbn,
h1("quality control"))
ui <- dashboardPage(header, sidebar, body)
server <- function(input, output){
oserveEvent(input$btn_switchtab, {
newtab <- switch(input$tabs,
"data" = "qcbn",
"qcbn" = "data"
)
updateTabItems(session, "tabs", newtab)
})
}
# Run the application
shinyApp(ui = ui, server = server)