Step Up Your Dashboard With Shinydashboard – Part 1: Exercises

Share Tweet

The shinydashboard package provides a well-designed dashboard theme for Shiny apps and allows for an easy assembly of a dashboard from a couple of basic building blocks. The package is widely used in commercial environments as well, due to its neat features for building convenient and robust layouts.

This exercise set will help you practice all of the main features of this great package. By completing the two parts of the exercise series, you’ll know that you’re ready to start building well-designed Shiny apps. We will make some minimal use of the built-in data-set datasets::CO2 (specific description of the data-set is irrelevant, but you can check it out by typing ?datasets::CO2). Each exercise is adding some more features/functionalities to the code of the previous exercise, so be sure to not discard the code until after you’re done with all of the exercises. Answers to these exercises are available here.

In the solutions page, you’ll first find only the relevant components of each exercise. Then, at the end of the page, you will find the entire Shiny app code that contains all of the different components together. It is advised to use the following template to get started with the exercises:

header <- dashboardHeader(...)
sidebar <- dashboardSidebar(...)
body <- dashboardBody(...)
ui <- dashboardPage(...)
server <- function(input, output, session) {}
shinyApp(ui = ui, server = server)

For other parts of the series, follow the tag shinydashboard.

Exercise 1
Set the title of the dashboard to be “Practicing shinydashboard.”
The font-family should be “Tahoma” and the font-weight should be “bold.”

Exercise 2
Since the title that we chose is a bit long, set the header and sidebar width to 300 pixels.

Exercise 3
Select a black skin to the dashboard.

Exercise 4
Select a title for the browser tab, which is different than the dashboard title.

Exercise 5
Add two menu items to the sidebar: one named “data” and one named “about.”
Change the font-size of the menu items to 20 pixels.

Exercise 6
Add icons of your choice next to the two menu items that you added.

Exercise 7
Add a yellow badge which says “New” next to the “data” menu item.

Exercise 8
Under the “about” menu item, add two sub-items: one named “licences” and one named “contact us.”

Exercise 9
Add a search box at the top of the sidebar with the label “What are you looking for?”
Hint: use sidebarSearchForm().

Exercise 10
Add a selectInput under the search box you just added.
The input ID should be plant and the choices should be unique(CO2$Plant).

Related exercise sets:

  1. Spatial Data Analysis: Introduction to Raster Processing (Part 1)
  2. Mathematical Expressions in R Plots: Tutorial
  3. Parallel Computing Exercises: Snow and Rmpi (Part-3)
  4. Explore all our (>1000) R exercises
  5. Find an R course using our R Course Finder directory
Share Tweet
__data