Chapter 7 Shiny
Shiny is an R package for creating a web site to interact with R. For example, a website could include various widgets for user input. User input data gets sent to a server running R, which then executes R code. Output from R can be sent back to the webpage in the form of data tables and graphs. A working example using the default shiny app available in R-studio is presented below. Note the shiny app will only display in the web-book version of this tutorial, and not the .pdf or epub versions.
knitr::include_app("https://shiny-crump-test.herokuapp.com",
height = "600px")
In the above example, the shiny app has loaded a dataset into R and plotted a histogram. The sidepanel contains a scrollbar that allows a user to change the bin-size of the histogram. When the scrollbar is moved the new bin-size settings are sent to the server, R recomputes the histogram, and the website dynamically shows a histogram with new bin-sizes.
This example shiny app is running as a standalone website, but it has been embedded inside the web-book see the example from bookdown for more info
7.2 A minimal working example using Heroku
Heroku is a flexible and free (with paid options) cloud-computing service that can be used to serve Shiny apps.
This repository shows an example of configuring Heroku to run an R shiny app: https://github.com/CrumpLab/testShinyHeroku