Step Up Your Dashboard With Shinydashboard – Part 2: Exercises

The shinydashboard 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 descriptions of the data-set are irrelevant, but you can check them 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 component 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. This exercise set is based on the output code of this exercise set. If you haven’t done it, you can just use the code under “All Exercises Combined” here (at the bottom) as your basis for this exercise set.

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

Exercise 1
In the “data” tab, add a box() with the title “CO2 Data.”
The box should have a blue header and it should be collapsible.

Exercise 2
Add the CO2 table to the box you just created.
The table should be filtered by the plant input that was created in the previous exercise set.

Exercise 3
In the “licenses” tab, add a tabBox() that contains two panels: one titled “Data” and one titled “Icons.”
You can leave those panels empty for now.

Exercise 4
In the “contact_us” tab, add an infoBox() with some content of your choice and select its color and icon.

Exercise 5
In the “contact_us” tab, add an valueBox() with some content of your choice, and select its color and icon.

Exercise 6
Add a “messages” drop down menu to the header.
Select its icon and badge-status and add one messageItem() to it.

Exercise 7
Add a “tasks” drop down menu to the header.
Select its icon and badge-status and add two taskItem()s to it.

Exercise 8
Add a placeholder for a “notifications” drop down menu in the header using dropdownMenuOutput().
The output ID should be “notifications.”

Exercise 9
Add the server-side code of the “notifications” drop down menu.
It should have a single notification item that shows what the current value of the plant input that was created in the previous exercise set is.

Exercise 10
Add a link to “r-exercises.com” in the header.
Hint: use tags$li(class = "dropdown", ...) together with tags$a(...).




Step Up Your Dashboard With Shinydashboard – Part 1: Exercises

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 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).