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

UI.R partial coding


As it was said before, the input widgets are the first part of the application that must be coded. In this case, almost all the widgets are on the side panel except the selectors that are used in the education-descending line chart and the earnings chi-square test that are in their corresponding tabs. Also, it is recommended to generate the application's frontend structure at this stage. So, the UI.R code that we have so far would be as shown in the following section.

UI.R

As it may be noted, the arguments of the widgets builders are determined dynamically. The reason behind this is exactly the same as in the creation of factor.vars in global.R: avoid hardcoding. Of course, there are some cases (for example, the sex variable) where this will be unnecessary, as it is impossible that the categories were changed even with a change in the data source. However, in cases such as age, it is perfectly possible that the minimum and maximum values change. So, this dynamic referencing...