Reputation: 31
My menuItems and menuSubItems do not show up when clicked on. It only stays on the default dashboard body. Please note, those subItems do not yet contain anything in them. I want to be able to open those pages before I include any data there.
I am following the tutorial from this YouTube playlist starting at video 10: https://www.youtube.com/playlist?list=PLH6mU1kedUy8c44XiTkGSEKRwojVHtsHm
install.packages(c("shiny","shinydashboard","ggplot2","dplyr"))
August <- dataframe("Revenue" = c(150,275,450,890,212,618),
"Team" = c(blue,blue,green,green,gold,gold))
ui <- shinyUI(
dashboardPage(
dashboardHeader(title = "August 2019"),
dashboardSidebar(
sidebarMenu(
menuItem("Dashboard",tabName = "dashboard"),
menuSubItem("By Team", tabName = "by team"),
menuItem("item2"),
menuItem("Raw Data")
)),
dashboardBody(
tabItems(
tabItem(tabName = "dashboard",
fluidRow(
box(valueBoxOutput("totalrevenue"))
)),
tabItem(tabName = "by team",
h1("Numbers by Team")
),
tabItem(tabName = "by customer",
h2("Numbers by Customer")
)))))
server <- shinyServer(function(input,output){
total.revenue <- sum(August$Revenue)
output$totalrevenue <- renderValueBox({
valueBox(
formatC(total.revenue, format = "d", big.mark = ',')
,paste('Revenue:',total.revenue)
,icon = icon("stats", lib = 'glyphicon')
,color = "blue")
})
})
shinyApp(ui, server)
I just need to be able to flip between pages on the dashboard.
Upvotes: 1
Views: 348
Reputation: 889
Seems like tabName = "by team"
does not like the empty space. You also have to name all your tabs. Try following
ui <- shinyUI(
dashboardPage(
dashboardHeader(title = "August 2019"),
dashboardSidebar(
sidebarMenu(
menuItem("Dashboard",tabName = "dashboard"),
menuSubItem("By Team", tabName = "byteam"),#remove empty space
menuItem("item2", tabName = "item2"), #give tab name
menuItem("Raw Data",tabName = "rawdata") #give tab name
)),
dashboardBody(
tabItems(
tabItem(tabName = "dashboard",
fluidRow(
box(valueBoxOutput("totalrevenue"))
)),
tabItem(tabName = "byteam", #remove empty space
h1("Numbers by Team")
),
tabItem(tabName = "item2",
h2("Numbers by Customer Tab")
),
tabItem(tabName = "rawdata",
h2("Raw Data Tab")
)))))
server <- shinyServer(function(input,output){
total.revenue <- sum(August$Revenue)
output$totalrevenue <- renderValueBox({
valueBox(
formatC(total.revenue, format = "d", big.mark = ',')
,paste('Revenue:',total.revenue)
,icon = icon("stats", lib = 'glyphicon')
,color = "blue")
})
})
shinyApp(ui, server)
Hope that helps!
Upvotes: 1