Reputation: 162
I have a simple shiny dashboard that has four tabs in the side menu, and for some reason, when I build the shiny app, clicking on the side menu does not show me a new page, and the content of tab2 just appends itself to tab1.
While searching stackoverflow showed me this question: Shinydashboars tabItems not working properly, the answer doesn't apply to me since I'm not using rmd, and i don't plan to host it to a AWS server.
Here is the code for reference:
ui <- dashboardPage(
dashboardHeader(title = "Study Dashboard"),
dashboardSidebar(
sidebarMenu(
menuItem("Overall Objectives", tabName = "objectives"),
menuItem("Wellpad Operator", tabName = "wellpad_operator"),
menuItem("Wastewater Expert", tabName = "wastewater_expert"),
menuItem("Freshwater Expert", tabName = "freshwater_expert"),
menuItem("Environmental Impact", tabName = "environ_impact")
)
),
dashboardBody(
#Tab 1 Objective View
tabItems(
tabItem(tabName = "objectives",
h2("Overall Objectives"),
fluidRow(
box(
title = "Overall Objective Comparison", width = 6, solidHeader = TRUE,
plotOutput("objective_plot")
),
box(
title = "Cost Category Breakdown", width = 6, solidHeader = TRUE,
plotOutput("costbreakdown_plot")
),
box(
title = "Decision Variables", width = 12, solidHeader = TRUE,
tableOutput("decision_table"))
))
),
#Tab 2 Wellpad Decision
tabItem(tabName = "wellpad_operator",
h2("Wellpad Operator")
),
#Tab 3 Wastewater Expert
tabItem(tabName = "wastewater_expert",
h2("Wastewater Expert")
),
#Tab 4 Freshwater Expert
tabItem(tabName = "freshwater_expert",
h2("Freshwater Expert")
),
#Tab 5 Environmental Damages
tabItem(tabName = "environ_impact",
h2("Environmental Impact"))
)
)
server <- function(input, output) {
#server side code that generates the plots
}
shinyApp(ui = ui, server = server)
Thanks for all your help!
Upvotes: 1
Views: 3856
Reputation: 2995
You need to put all your tabItem
inside tabItems
. Try this:
dashboardBody(
#Tab 1 Objective View
tabItems(
tabItem(tabName = "objectives",
h2("Overall Objectives"),
fluidRow(
box(
title = "Overall Objective Comparison", width = 6, solidHeader = TRUE,
plotOutput("objective_plot")
),
box(
title = "Cost Category Breakdown", width = 6, solidHeader = TRUE,
plotOutput("costbreakdown_plot")
),
box(
title = "Decision Variables", width = 12, solidHeader = TRUE,
tableOutput("decision_table"))
)),
#Tab 2 Wellpad Decision
tabItem(tabName = "wellpad_operator",
h2("Wellpad Operator")
),
#Tab 3 Wastewater Expert
tabItem(tabName = "wastewater_expert",
h2("Wastewater Expert")
),
#Tab 4 Freshwater Expert
tabItem(tabName = "freshwater_expert",
h2("Freshwater Expert")
),
#Tab 5 Environmental Damages
tabItem(tabName = "environ_impact",
h2("Environmental Impact"))
)
)
Upvotes: 3