【问题标题】:sidebar pages not opening in shiny dashboard侧边栏页面未在闪亮的仪表板中打开
【发布时间】:2019-12-21 04:54:45
【问题描述】:

我的 menuItems 和 menuSubItems 在单击时不显示。它仅保留在默认仪表板主体上。请注意,这些子项还没有包含任何内容。我希望能够在其中包含任何数据之前打开这些页面。

我从视频 10 开始关注此 YouTube 播放列表中的教程: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)

我只需要能够在仪表板上的页面之间切换。

【问题讨论】:

    标签: r shiny shinydashboard


    【解决方案1】:

    似乎tabName = "by team" 不喜欢空白区域。您还必须命名所有选项卡。尝试关注

    
    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)
    
    

    希望有帮助!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-10-21
      • 2018-12-24
      • 1970-01-01
      • 1970-01-01
      • 2016-12-05
      • 2016-11-24
      • 1970-01-01
      • 2017-04-23
      相关资源
      最近更新 更多