• Tech Tips
  • 01.29.24

A Three-part Series on the Application and Production of Shiny Applications for IR: Part 3

  • by Gina Deom, Jesse Talley, Michael Sauer , and Stefano Fiorini, Indiana University

 

This is the third and final part (see Part 1 and Part 2) of a three-part tutorial on why and how to adopt Shiny applications for IR offices. In this section, we will build on the main components introduced in the previous installments and provide you with an overview of some more advanced, technical topics for Shiny web application development. We conclude with a brief discussion of challenges and opportunities followed by a list of resources you can reference for future learning.

Shiny Input Controls

The Big 10 example presented in Part 2 used a radio button input control object to collect inputs from the user. However, there are numerous other input controls available in Shiny such as checkboxes, drop-down boxes, sliders, etc. The equity example in Part 2 also leveraged checkboxes and drop-down menus, for example. The Shiny input controls can even be free text fields, and file upload features that allow you to upload files by connecting to the file system browser on your computer, for example. The specific input control(s) you choose might depend on a variety of factors such as the data type of variables used in your web application, the amount of space you have available in the User Interface (UI), the number of possible options that you want a user to select from at any given time, and the intended purpose of your web application.

The R functions for the input controls generate HTML that produces the desired control in the UI. Since the R functions for each type of Shiny input control are documented in a number of free online resources, including Chapter 2 of Mastering Shiny (Wickham, Hadley) and the Posit Shiny Cheatsheet, we will spare you from the details of them here. However, on the code side, know that there will generally be two common arguments across each of these functions: inputId and label.  The inputId argument sets a unique identifier for the input control so that it can be used and referenced in the server component of the R code to process information and create outputs. The label argument creates a friendly title for the user control that is displayed in the UI.

Shiny Outputs/Rendering

The output created in the Big 10 example was a simple text object based on which Big 10 institution a user selected in the UI. The server’s purpose is to process the information from the UI and update objects that are displayed in the UI. As such, there are a variety of “render” functions (e.g., renderText, renderPlot, renderTable, etc.) that can be placed in the server and paired with a corresponding “output” function in the UI (e.g., verbatimTextOutput, plotOutput, tableOutput, etc.). Since the goal of the Big 10 example was to display the selected institution as text in the UI, the pair of render and output functions that were called in the UI and server code were verbatimTextOutput and renderText, respectively. The equity example in Part 2 leveraged plotOutput and renderPlot functions to display the mosiac plot. Both Chapter 2 of Mastering Shiny (Wickham, Hadley)and the Posit Shiny Cheatsheet show the mapping of which pairs of functions are needed to render and display different types of outputs in your web application.

Layout and Themes

Shiny applications are fundamentally HTML documents, which means that they can still be enhanced with HTML to create the content and structure of the page, CSS to provide the style and design, and JavaScript to add animations and popups (Shiny - RStudio). There are various functions and extension packages that add capacity in these areas.

For example, instead of using the basic fluidPage function to create a simple single page layout as we did in our Big 10 example, we might want to structure our web application like we did in the equity example with separate panels by 1) having a side panel which houses any filters or controls and 2) displaying the output in the main panel. Or, we may want our web application to be organized into different sheets or tabs. You can see examples of how to create these layouts in Chapter 6 of Mastering Shiny (Wickham, Hadley). The shinydashboard package also has some built-in layouts that are conducive for dashboard creation.

Additionally, the shinythemes package provides built-in themes that tap into CSS to control the style and design of the page. In both examples in Part 2, we leveraged the “cerulean” theme from that package to add blue elements to navigation bars, action buttons, and heading text. At the time this tutorial was written, over 15 different themes were available for use from the package.

Finally, there are several functions and packages that leverage JavaScript for popup features. For example, there are some functions that allow the user to download files (such as datasets and R code) from the application; after users select buttons to download files, pop ups are generated that allow the user to navigate to their downloads folder to access the files. While not touched on in this tutorial, the shinyjs package has other functions that create JavaScript for Shiny apps that may be worth exploring.

Deploying Shiny Applications: Challenges and Opportunities for Diffusing Analytics at our Campuses

Since Shiny web applications are html documents, they can be hosted online or on an internal server. In other words, you can develop your web application, publish it, and then provision access to stakeholders on campus. However, as indicated in a recent eAIR tech tips article, this poses a challenge to IR because most data deliverables produced by IR offices serve an internal audience. To ensure that these Shiny applications are only visible to an internal audience, a university needs 1) an internal Posit Connect server and 2) the specific security protocols in place to manage user permissions for individual objects published on that server. Some institutions have an internal server through Posit Connect for posting reports and applications, but in some cases, the server has not been cleared for storage of FERPA-protected data. This can be a substantial roadblock for IR offices. IR staff need to work closely with information technology and data security staff on their campuses as well as Posit Connect representatives to develop solutions for security and provisioning access.

Conclusion and Additional Resources

This concludes our three-part series on creating Shiny applications for IR offices. We hope you have found this series informative and helpful. Please do not hesitate to contact us at iara@iu.edu. Below is a list of resources that might be helpful for future learning.

Education Analytics | Using Shiny to enhance the interpretation and… (edanalytics.org)

Github Resources for this eAIR Tech Tips Article

Mastering Shiny by Hadley Wickham

Posit Connect

R Shiny for Data Science Tutorial – Build Interactive Data-Driven Web Apps

Shiny :: Cheatsheet (rstudio.github.io)

Shiny for R Gallery (posit.co)

Shiny Product Overview

Welcome to Shiny: Get Started Lessons

 

 


DeomGina Deom has nearly 10 years of experience working in higher education data and research. She currently serves as a data scientist with the Research and Analytics team, a subunit within Indiana University’s Institutional Analytics office. Gina has given several presentations at national and international conferences, including the SHEEO Higher Education Policy Conference, the NCES STATS-DC Data Conference, the Learning Analytics and Knowledge (LAK) Conference, and the AIR Forum. Gina has earned a best paper award from INAIR, AIR, and LAK.

 

TalleyJesse Talley has over seven years working in higher education data and research, including four years in institutional research and three years in survey research and administration. He currently serves as a data analyst at Indiana University’s Institutional Analytics office. Jesse has collaborated on previous conference presentations for the AIR, INAIR, the American Association of Public Opinion Research, and the Midwest Association for Public Opinion Research. He also contributed a methodological report for an NSF project, portions of which were published in a peer-reviewed journal.  

 

Sauer Michael Sauer  is Lead Information Management Analyst for Research and Analytics at Indiana University. Mike began his career in institutional research at IU in 2002, and currently serves as an Information Analyst on the Research and Analytics team. Prior to his time in institutional research, he taught Spanish and Portuguese at IU. He holds a Certificate in Underwater Resource Management from IU, is a certified yoga instructor and an Indiana Master Naturalist. He enjoys being with family, reading, observing nature, watching IU sports and learning languages. Mike holds a Master of Public Affairs in Environmental Policy and Natural Resource Management, a Master’s in Latin American and Caribbean Studies (both from Indiana University), and a Bachelor’s in History from the College of Wooster.

 

FioriniStefano Fiorini Ph.D. is a Social and Cultural Anthropologist with the Research and Analytics team, a subunit within Indiana University’s Institutional Analytics office. He has extensive applied research experience in the areas of institutional research and learning analytics. He has published in peer reviewed journals and conference proceedings and presented at national and international conferences (e.g. AIR Annual Forum, CSRDE, LAK), earning best paper awards from INAIR, AIR and SoLAR.