13 Shiny

Lets you present tables and charts that will react to inputs.

13.2 User Interface

13.2.2 Inputs

There are various Inputs that can be added to the UI. Behind the scenes these generate HTML code: * sliderInput() # Adds an input slider * fileInput() # Adds a file selector * textInput() # Adds a text input box * selectInput() # Adds a dropdown list * actionButton() # Adds an action button * dateRangeInput() # Adds a date selector The first argument of all the inputs/ouputs is a unique id.

13.2.3 Outputs

There are various Outputs that can be added to the UI: * htmlOutput() # Adds space for text * tableOutput() # Adds space for a table * plotOutput() # Adds space for a chart

Nb. these will be empty until a function is added to the server that adds content.

Other packages extend shiny ui outputs. * plotlyOutput # Adds space for a plotly chart [plotly] * ggiraphOutput # Adds space for a ggiraph chart [ggiraph] * DTOutput # Adds space for a data table [DT]

13.3 Server

UI inputs and outputs wont work unless they link to a server process/function.

13.3.1 Linking to UI outputs

  • renderPlot() # creates reactive ggplot output
  • renderText() # creates reactive tetx output
  • renderTable() # creates reactive table output
  • renderDataTable() # creates reactive DT output The UI output id and the server output name must match.

Other packages extend shiny server outputs. * renderPlotly # creates reactive plotly chart [plotly] * renderggiraph # creates reactive ggiraph chart [ggiraph]

13.4 Shiny Dashboard

Provides a dashboard template for Shiny Apps.

library(shiny) library(shinydashboard)