开始使用免费开始使用

主体与完成 UI

您已经设置好了headersidebar。现在,来设置 body

这是线框图设计中的关键一步,有助于您决定在仪表板主体中将各个输出和输入放在什么位置。

在本练习中,您将在仪表板中放置多个输出和输入。完成后,您将得到用户界面的三大组件,它们会一起放入 dashboardPage() 中。

<说明:由于包含一些隐藏函数,此仪表板无法在本地完全复现。>

本练习是课程的一部分

使用 shinydashboard 构建仪表板

查看课程

交互式实操练习

通过完成这段示例代码来试试这个练习。

header <- dashboardHeader(title = "Soccer tournament")

sidebar <- dashboardSidebar(
  sidebarMenu(
    menuItem("Matches", tabName = "matchtab", icon = icon("futbol")), 
    menuItem("General statistics", tabName = "statstab", icon = icon("chart-line")) 
  )
)

body <- dashboardBody(tabItems(
  tabItem(tabName = "matchtab", 
  fluidRow(selectInput("match", "Match number", choices = 1:nrow(soccer))) 
         ),
  # See that the second tab should contain three sub-tabs
  ___(tabName = ___, 
          ___(tabPanel("Goals"), 
                 ___("Yellow cards"),
                 ___(___))
         )
))
编辑并运行代码