Getting started with shinyApps

Building Dashboards with shinydashboard

Png Kee Seng

Researcher

Why create a dashboard?

  • A report is static
  • Unlike a report, a dashboard is dynamic
  • It provides users with a more immersive experience
  • shinydashboard provides an intuitive way to create a dashboard in R

A stock image of a report, which is static -- it provides a snapshot of the situation.

1 Source: WikiMedia
Building Dashboards with shinydashboard

An example of a shinydashboard

An example of a shinydashboard. See that there are many interactive elements that we can place in there.

Building Dashboards with shinydashboard

shinyApp

  • A shinydashboard is a type of shinyApp
  • It has two main components:
    • A user interface (UI)
    • A server

An example of a shiny app from Rstudio

Building Dashboards with shinydashboard

The restaurant analogy

  • A shiny app is like a restaurant
  • A user of the shinyApp is like a patron
  • A user interface contains outputs and inputs
    • The output is like the dishes
    • The input is like the order
  • The waiter passes down the order to the kitchen and brings the food to us
    • The server tells the app what output to produce based on the user input

A user of the shinyApp is like a patron of a restaurant.

The waiter passes down the order to the kitchen and brings the food to us.

1 Image by macrovector on Freepik
Building Dashboards with shinydashboard

User interface (UI)

  • Import shiny
  • User interface (ui): fluidPage()
  • In the UI, app elements are added
    • E.g., title with titlePanel()
  • Server: user-defined function called server()
  • shinyApp() glues them all together and renders the app
library(shiny)
ui <- fluidPage(titlePanel("Your first app"))
server <- function(input, output){
}
shinyApp(ui, server)
Building Dashboards with shinydashboard

The rendered shinyApp

The shinyApp that is rendered from the code in the previous slide. See that it is an empty app with no inputs or outputs.

Building Dashboards with shinydashboard

Let's practice!

Building Dashboards with shinydashboard

Preparing Video For Download...