Building an application inside R

To build an application inside R, you need to understand how reactivity works. I'll explain it with an analogy using WhatsApp. Imagine your WhatsApp as the input object and you as the output object; any time a friend (the user) sends you a message, WhatsApp rings, alerting you about it, so you answer your friend with a new message based on what he/she wrote you. This is how reactive works in R's shiny package. Any time the user interacts and changes the value of an input, it alerts the server function that the output is outdated. So, the server function returns the code, pulling the new value inside the input$* variable, then returns the updated output.

It is important to know how it work mainly because there are situations where the server function can't rerun the code properly if a reactive expression isn't used. Reactive expressions are objects defined to alert the server function only when a specific interaction is executed; the interaction necessary to activate it varies according to the reactive expression used. We've already seen one kind of reactive expression, the render functions, which were used to display the output. Let's see other cases.

After requiring the shiny package in your R console, try to call ?reactive. It will open the R documentation about the reactive function, and it can help you to better understand reactivity in Shiny.
..................Content has been hidden....................

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