開始使用免費開始

設定標頭

在影片中,標頭被比喻成餐廳的招牌或門面。

在標頭中,你可以設定 shinydashboard 的標題,並加入其他元素。你也看過各種型別的下拉清單,裡面可以放不同類型的項目。

在這個練習中,想像你已經完成了一個全球足球錦標賽的統計分析。你現在想建立一個儀表板來呈現這些結果。為此,你會先設定標頭。

shinyshinydashboard 套件已替你載入。

本練習屬於課程

使用 shinydashboard 建立儀表板

檢視課程

練習說明

  • title 設為「Analysis results for global soccer tournament」。
  • 將標題寬度設為 400。
  • 建立 1 個 型別 為「messages」的下拉清單,其中包含 1 個訊息項目。
  • 再新增 1 個 型別 為「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)
編輯並執行程式碼