You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to get both the page and sidebar to change based on the selectInput using renderUI and uiOutput.
Here is a very simple reprex wherein the server's renderUI function operates based on the selectInput to render either a "data" or a "visualize" page and sidebar.
library(shiny)
library(shinydashboard)
library(shinydashboardPlus)
ui <- dashboardPage(
header = dashboardHeader(
title = "My Shiny App",
tags$li(class = "dropdown",
selectInput("menu", "Menu:",
choices = c("Data", "Visualize"),
selected = "Data"))
),
sidebar = dashboardSidebar(
uiOutput("sidebar_content")
),
body = dashboardBody(
uiOutput("page_content")
)
)
server <- function(input, output) {
output$sidebar_content <- renderUI({
if (input$menu == "Data") {
sidebarMenu(
menuItem("Data Page", tabName = "data_page")
)
} else {
sidebarMenu(
menuItem("Visualize Page", tabName = "visualize_page")
)
}
})
output$page_content <- renderUI({
if (input$menu == "Data") {
tabItems(
tabItem(tabName = "data_page",
fluidRow(
column(12,
h3("This is the Data page"),
p("Here you can view and edit your data.")
)
)
)
)
} else {
tabItems(
tabItem(tabName = "visualize_page",
fluidRow(
column(12,
h3("This is the Visualize page"),
p("Here you can visualize your data.")
)
)
)
)
}
})
}
shinyApp(ui, server)
But running the App returns this error:
"Error in dashboardHeader(title = "My Shiny App", tags$li(class = "dropdown", :
attempt to apply non-function"
Any ideas? Should this be possible?
Thanks,
echo
The text was updated successfully, but these errors were encountered:
I'm trying to get both the page and sidebar to change based on the selectInput using renderUI and uiOutput.
Here is a very simple reprex wherein the server's renderUI function operates based on the selectInput to render either a "data" or a "visualize" page and sidebar.
But running the App returns this error:
"Error in dashboardHeader(title = "My Shiny App", tags$li(class = "dropdown", :
attempt to apply non-function"
Any ideas? Should this be possible?
Thanks,
echo
The text was updated successfully, but these errors were encountered: