We’ve now covered everything we need to make our app. We’ll first replace the histogram with a (non interactive) gapminder plot. We’ll then create a widget to let us select the year. Finally, we’ll wire everything together to make the app interactive.
produceGapminderPlot()
requires a single year of data, so you will need to filter()
the data to a single year before passing it to the function.The outputId
of the plot in the default app is distPlot
- you should change this to something more descriptive, e.g. gapminderPlot
. Remember to change this in both the server function, and in the user interface.
Create a new widget, with inputId="year"
(or modify the bins
widget) to let the user choose the year of data to plot. You might want to check out the sep
option to deal with the thousand separator commas, and step
to alter the “resolution” of the slider.
(optional) check out the options for the sliderInput()
widget and add an animation button.
The performance of the app isn’t great in the virtual machine. You may need to set the interval
option to reduce the frame rate and prevent the animation lagging.
bins
widget as we are no longer using this.We’ve now built our Shiny app. To recap:
renderPlot()
, and other types of output using render....()
functionsplotOutput()
(or ...Output()
for other types of output) in your user interfaceinput$inputID
In the next section we’ll look at options for deploying our app.