Don’t repeat yourself: Templatize your R Shiny Apps with Modules
Regular talk, 1:10-1:25
A central philosophy of coding in R is if you find yourself repeating code, it’s time to write a function. The same goes for R Shiny development—if you find yourself repeating code it’s time to modularize. But what about when you find yourself repeating features and functions across different apps? Then it’s time to make a template. In this talk, you’ll learn when, why, and how you can reuse your app features by templatizing your existing apps with a modular structure and the rhino package. At GSI Environmental, the need for a template arose as we continued to get requests for similar data viewer apps. Groundwater remediation and monitoring projects in particular all have the same need for interactive site maps, trend analysis, time series plotting, and the ability to explore data with various filters. Creating a template has allowed us to spend less time developing these apps, and more time on project-specific analysis. Modularity is the essential pre-requisite for an effective R Shiny template. This talk will provide a high-level guide to getting started with modularity and the rhino package structure for apps. In addition to frequently used modules and reactive values, styling and UI are also critical features of a template. I’ll show you how to organize all the pieces for maximum re-usability and easier debugging. While not strictly essential, standardized data management can make your template even more useful. With the environmental data we work with, most projects use a standardized data structure. This means that we can also re-use more of our data-handling code and templatize data-filtering reactive features that are specific to the data. The data viewer template that we’ve developed at GSI continues to evolve with styling updates, new modules, and improved reactivity flows. It serves as a central R Shiny codebase for the whole team. Our goal is to integrate our apps directly with our databases as our company evolves its data management strategy. This talk will share the lessons that we’ve learned and provide a quick-start guide to streamlining your app development with a modular template.
Pronouns: she/herOlympia, WAErica Bishop is an Environmental Data Scientist at GSI Environmental in Olympia, WA. She uses R for statistical analysis, data visualization, and Shiny App development to support a wide range of environmental monitoring, remediation, and risk assessment projects. She delights in translating the complexities of the environment into plots, maps, and apps. When Erica is not behind the computer, she enjoys reading fiction and mountain biking. |