开始使用免费开始使用

设置页眉

在视频中,页眉被比作餐厅的招牌或门头。

在页眉中,会定义 shinydashboard 的标题,并可添加其他元素。尤其是,您看到了包含多种项目的不同类型下拉列表。

在本练习中,假设您已经完成了对全球足球锦标赛部分统计数据的分析。现在,您想创建一个仪表板来展示这些结果。为此,您将首先设置页眉。

shinyshinydashboard 包已为您加载。

本练习是课程的一部分

使用 shinydashboard 构建仪表板

查看课程

练习说明

  • title 设置为 "Analysis results for global soccer tournament"。
  • 将标题宽度设置为 400。
  • 创建一个 type 为 "messages" 的下拉列表,包含 1 个消息项目。
  • 再添加一个 type 为 "notifications" 的下拉列表,包含 1 个通知和 1 个任务项目。

交互式实操练习

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

header <- dashboardHeader(
  # Set the title as "Analysis results for global soccer tournament"
  ___,
  # Set the title width to 400
  ___,
  # Add a dropdown menu containing two messages
  dropdownMenu(type = ___,
       ___("Colleague", "Hello world!")),
  # Add another dropdown menu containing two other items
  ___(___,
       ___("Have you rested today?"),
       ___("Dashboard completion", value = 20)))
sidebar <- dashboardSidebar(); body <- dashboardBody()
ui <- dashboardPage(header, sidebar, body); server <- function(input, output){}
shinyApp(ui, server)
编辑并运行代码