Introduction to Shiny and the reactivity framework

To make things even more interesting, we are now going to add a small piece of the Shiny application within our paragraphs.

As we were saying before, the shiny package was developed to let people programming in R easily build web applications to share results of their analyses. Well, just to be clear from the beginning: saying that shiny develops web applications doesn't mean that you need a web server to employ the package. It just means that what shiny produces is ready, with some further steps that we are not going to see now—to be published on the Web.

Without looking at all the complexity behind the scenes, we can say that a shiny web app is built of three basic components:

  • A user interface : ui <- fluidPage()
  • A server: server <- function(input, output, session) {}
  • A function calling the app: shinyApp(ui, server)

In the standard setting of a Shiny App, you will have to develop all the data mining and plotting activities in the server function, leaving to the ui function the responsibility of disposing their output in the best possible way for the user.

Given this static picture, there is one more layer that adds flexibility to the app--reactivity. The idea behind reactivity is quite simple. Through some controls are available within the user interface specified by the ui, the user can select parameters or specify filtering options. Given this, within the server side of the function, these new inputs can be considered to update the data mining and plotting activities previously performed.

As you might expect, this will produce an updated result to be shown within the user interface. What if the user now changes some of the filtering parameters again? You got it! Everything changes again.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset