Get startedGet started for free

Outputs

1. Outputs

We've covered inputs, but without output or render functions, inputs aren't yet very useful in your app. Let's learn more about outputs and render functions so you can build a full app.

2. Render functions

Render functions are used to build outputs in the server based on inputs and possibly other things, like other parts of a character string, as in this example. Recall our question and answer app, which you saw the code for in the last lesson. This app outputs two different character strings, one with a question and one with the answer. Given they're both character strings, it's appropriate to use the renderText function to create both outputs.

3. Other render functions

Like inputs, Shiny provides a number of other render functions you can use to create a number of different kinds of outputs beyond just text, including rendertable, renderImage, renderPlot, and more. The Shiny documentation is a great place to go to find out about more render functions available to you.

4. Output functions

Output functions are used back in the UI to display the outputs built in the server with render functions. For our question and answer app, we used two textOutput functions to display both the question and the answer outputs.

5. Other output functions

Like inputs and render functions, Shiny provides a wide variety of outputs depending on what kind of output you've built, whether that be a table, an image, or a plot.

6. Non-Shiny output and render functions

There are packages outside of Shiny that provide ways to build outputs with render and output functions. Thanks to htmlwidgets, packages such as DT, leaflet, and plotly allow you to build interactive data tables, maps, and plots as Shiny outputs. For example, the DT package allows you to build interactive data tables versus static ones. This code, for example, will build an app creating an interactive data table version of a random 10% of the babynames dataset we've been using throughout the course. Notice that we use the renderDT function to build the output in the server, then the DTOutput function in the ui to display the table, which we called babynames_table. The interactive table is sortable, searchable, plus users can choose to show 10, 25, or more entries at a time.

7. Let's practice!

Now that you know how to use outputs and render functions, you can practice building complete apps.