Get startedGet started for free

Setting a header

In the videos, the header was likened to the signboard or front-end of a restaurant.

In the header, the title of the shinydashboard is defined, and additional elements can be added. Particularly, you saw various types of dropdown lists containing various types of items.

In this exercise, imagine that you have already carried out an analysis of some statistics for a global soccer tournament. You now want to create a dashboard as a means to present these results. To this end, you will first set up the header.

The shiny and shinydashboard packaged have already been loaded for you.

This exercise is part of the course

Building Dashboards with shinydashboard

View Course

Exercise instructions

  • Set the title as "Analysis results for global soccer tournament"
  • Set the title width to 400.
  • Create one dropdown list of type "messages" containing one message item.
  • Add another dropdown list of type "notifications" containing one notification and one task item.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

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)
Edit and Run Code