R Shiny 仪表盘 - 是否有类似于 navbarPage 的功能?

3

我在 R 中制作了一个 shinydashboard 以显示所有数据,比标准的 shiny 看起来更好。

我正在尝试找出如何在仪表板中执行“navbarPage”的相当操作(即拥有多个页面来显示不同的数据,而不是将所有数据放在同一页上的不同框中)。

我尝试简单地添加 "navbarPage(" 到代码中,但这会出现多个错误。


2
https://rstudio.github.io/shinydashboard/get_started.html - kristang
1个回答

0
在Shiny Dashboard入门页面上的示例可以回答你的问题。为了方便起见,这里是它的内容。
    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
    })
  }
)

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接