简体   繁体   English

R Shiny Dashboard-等同于navbarPage?

[英]R Shiny Dashboard - equivalent to navbarPage?

I have made a shinydashboard in R to show all of my data, as looks better than standard shiny. 我在R中制作了一个shinydashboard来显示我的所有数据,因为它看起来比标准闪亮更好。

Trying to figure out how to do the equivalent of "navbarPage" in the dashboard (ie have multiple pages that show different data, rather than having all the data in different boxes on the same page). 试图弄清楚如何在仪表板中执行等效的“navbarPage”(即,有多个页面显示不同的数据,而不是将所有数据放在同一页面上的不同框中)。

I tried to do simply add "navbarPage(" to the code but this comes up with multiple errors) 我试图将“ navbarPage(”)添加到代码中,但这会出现多个错误。

The example at shiny dashboard get started page answers your question. 闪亮的仪表板入门页面上的示例回答了您的问题。 For your convenience, here it is. 为了您的方便,这里。

    body <- dashboardBody(
  fluidRow(
    tabBox(
      title = "First tabBox",
      # The id lets us use input$tabset1 on the server to find the current tab
      id = "tabset1", height = "250px",
      tabPanel("Tab1", "First tab content"),
      tabPanel("Tab2", "Tab content 2")
    ),
    tabBox(
      side = "right", height = "250px",
      selected = "Tab3",
      tabPanel("Tab1", "Tab content 1"),
      tabPanel("Tab2", "Tab content 2"),
      tabPanel("Tab3", "Note that when side=right, the tab order is reversed.")
    )
  ),
  fluidRow(
    tabBox(
      # Title can include an icon
      title = tagList(shiny::icon("gear"), "tabBox status"),
      tabPanel("Tab1",
        "Currently selected tab from first box:",
        verbatimTextOutput("tabset1Selected")
      ),
      tabPanel("Tab2", "Tab content 2")
    )
  )
)

shinyApp(
  ui = dashboardPage(
    dashboardHeader(title = "tabBoxes"),
    dashboardSidebar(),
    body
  ),
  server = function(input, output) {
    # The currently selected tab from the first box
    output$tabset1Selected <- renderText({
      input$tabset1
    })
  }
)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM