Book Image

Learning Shiny

By : Hernan Resnizky
Book Image

Learning Shiny

By: Hernan Resnizky

Overview of this book

Table of Contents (19 chapters)
Learning Shiny
Credits
About the Author
Acknowledgements
About the Reviewers
www.PacktPub.com
Preface
Free Chapter
1
Introducing R, RStudio, and Shiny
Index

server.R coding


After analysis and the application's design, this is definitely the most important stage of coding. A well-programmed backend is the key to performance and consequently effective visualizations. In this part, as in every backend process, the focus should be on producing the output with as little code and processing as possible. In order to achieve this, the key is to avoid repetition.

In our example, all the outputs are produced from the same dataset, which is basically the data source filtered by the corresponding input values. As it was explained in Chapter 5, Shiny in Depth – A Deep Dive into Shiny's World, there is no need to generate the same object for every visualization, as a reactive object can be used instead. In this example, a reactive object is precisely used:

#Reactive subset

data.sset <- reactive({
  input$submitter
  isolate({
    subset(data.adult, sex %in% input$gender & age >= input$minage &
    age <= input$maxage & marital.status ...