4.1 Outputs - render()

 Basic Shiny Application Server - Output

Figure 4.1: Basic Shiny Application Server - Output

4.1.1 renderUI()

This is the renderUI function renderUI(expr, env = parent.frame(), quoted = FALSE,outputArgs = list()). It reactives HTML using the Shiny UI library.

Using uiOutput() and renderUI() to render selected parts of the UI with code. You can see that we had 2 “renderUI” on the server of this app.

  • The first renderUI creates a selectInput(), and the output id is var. So in the ui you will call uiOutput("var") to create the ui

  • The second renderUI creates a downloadButton(), and the output id is dl_butt. So in the ui you will call uiOutput("dl_butt") to create the ui

4.1.2 renderPlot()

 Basic Shiny Application Server - Reactivitiy

Figure 4.2: Basic Shiny Application Server - Reactivitiy

renderPlot() renders a responsive plot suitable for assignment to an output location. Then in the ui, call plotOutput()

Example:

I want to create the histogram chart when the user has selected a continuous variable, or the bar chart when the variable is a character or a factor. To do this I need to create a plot, in this case I saved the plot using the values$plot object, then I want to render a plot responsive, I need to call the renderPlot function ", after that I used plotOutput() in ui to display the output in the desired tab.

4.1.3 renderDT()

renderDT() renders a responsive table widget. This is the renderDT() function renderDT(expr, server = TRUE, env = parent.frame(), quoted = FALSE, funcFilter = dataTablesFilter, ...).

Example:

I want to generate a table, which includes the following:

  • Filter function.
  • 3 buttons: copy, print and download. There is a drop down option for the Download button, the user can download in csv, excell or pdf format.
  • The table has a page length of only 10 rows
 Basic Shiny Application renderDT - DTOutput

Figure 4.3: Basic Shiny Application renderDT - DTOutput