Shiny is a great tool for the working data scientist that needs to quickly build an MVP data product, but also wants to build a long-lasting "productionized" application.
The following is a (perpetually WIP) compendium of books, help documents, blog posts, etc. that I've found helpful when building Shiny apps.
As always, R Studio has a very helpful Shiny cheat sheet,
and you should follow the shiny
tag on Stack Overflow.
- Foundations
- Advanced
- Reactive Programming
- Development Workflow
- Data Visualization
- Shiny in Production
- UI/UX
- Docker and AWS
- HTML, CSS, and JavaScript
- Mastering Shiny is a WIP book by R hero Hadley Wickham.
- The official R Studio Shiny documentation
- R Powered Web Applications with Shiny: A Tutorial and Cheat Sheet with 40 Example Apps
- How to Build a Shiny App from Scratch
- Maintaining State with
reactiveValues()
- The
observe()
vs.observeEvent()
section of the Common Application Caveats chapter of Engineering Production-Grade Shiny Apps provides a lucid comparison of these functions
Remember the 4 maxims of reactive programming in Shiny prepared by Garret Grolemund:
- R expressions update themselves, if you ask.
- Nothing needs to happen instantly.
- The app must do as little as possible.
- Think carrier pigeons, not electricity.
Joe Cheng's two presentations on reactivity from Shiny DevCon 2016 are excellent places to start to learn about the programming model used by Shiny.
I found the following article to be especially clear at comparing reactive expressions and observers:
- The Workflow chapter in Hadley Wickham's Mastering Shiny has a lot of good advice. In particular, the part of Shiny apps in background jobs when using R Studio.
- A simple change that works for me is Dean Attali's tip
to put
session$onSessionEnded(stopApp)
in yourserver
function, which lets you "[a]utomatically stop a Shiny app when closing the browser tab." - MarkeD's answer to on the Best Practices: Shiny Development on the R Studio community discussion board has good suggestions.
- A Minimal Reprex for a Shiny App
shinysnippets
- R Shiny DT: Edit Values in Table with Reactive
- Editable DataTables for Shiny Applications discusses the
DTedit
package - How to Download Editable DataTable in Shiny
- See section 2.4 Edit Tables in RStudio's Using DT in Shiny documentation.
- Modify a Column of a Reactive DataTable in Shiny
- Profiling a Shiny App using
profvis
- Hadley's chapters on Measuring Performance and Improving Performance of R code in Advanced R will be helpful here.
- Speed Up Shiny Coding with Data
- 4 Tips to Make Your Shiny Dashboard Faster
- Speeding Up a Shiny App: Future/Promise and Caching
- Using
bindCache()
to Speed Up and App - Make Shiny Fast by Doing as Little Work as Possible
- A Beginner's Guide to Shiny Modules
- The Shiny Module Design Pattern
- Writing Big Apps: How to Use Shiny Modules
- Effective Use of Shiny Modules in Application Development
- Reproducible Shiny App Development with Modules
- Communication between Modules and Its Whims
- How to Safely Remove a Dynamic Shiny Module
- Shiny: Add/Removing Modules Dynamically
- Async in R and Shiny
- An Informal Intro to Async Shiny
- Improving Scalability with Async Programming
- Using Promises with Shiny
- Interactive Web-Based Data Visualization with R, Plotly, and Shiny
- R Graphics Cookbook (2nd Edition)
- The {ggiraph} package "makes ggplot graphics interactive, and you can check out its Shiny usage.
- Interactive Visualizations
What is "production"? Software environments that are used and relied on by real users, with real consequences if things go wrong.
--- Joe Cheng
- The Shiny AWS Book is a free book that covers "[t]he enterprise-grade process for deploying, hosting, and maintaining Shiny web applications using AWS, Docker, and git."
- Alternative Approaches to Scaling Shiny with RStudio Connect, ShinyProxy, or Custom Architecture
- Engineering Production-Grade Shiny Apps is another WIP book by the authors of the
{golem}
package. - Supplement to Shiny in Production
- Scaling Shiny Apps with Asynchronous Programming
- Production-Grade R Shiny with Golem: Prototyping
- Joe Cheng's Shiny in Production: Principles, Practices, and Tools presentation at rstudio::conf 2019
- Packaging Shiny Applications: A Deep Dive
- Building a Shiny App as a Package
shinyApp()
,runApp()
,shinyAppDir()
, and a Fourth Option- Dockerized Shiny App Development
- Demonstration of the
{golem}
Package is a nice quickstart webinar on using the{golem}
package. - Bring Your Favorite Fonts to Reports Running in Docker
- What's a "Successful" Shiny Application?
- R Shiny in Production
- Our Template to Design a Prod-Ready Shiny Application
- Debugging Shiny Applications
- Shiny Server Administrator's Guide
- What Does "Disconnected from Server" Mean in shinyapps.io?
- Deploying End-to-End Data Science with Shiny, Plumber, and Pins
- Scaling R Shiny: How We Built a Shiny App for 700 Users
- How to Scale Shiny Dashboards
- Using
drake
for ETL: Building a Shiny Real Estate App
ShinyProxy is your favourite way to deploy Shiny apps in an enterprise context. It has built-in functionality for LDAP authentication and authorization, makes securing Shiny traffic (over TLS) a breeze and has no limits on concurrent usage of a Shiny app.
- Shiny in Production with ShinyProxy, Docker, and Debian
- ShinyProxy official docs
- A Tale of Two Shiny Apps: Google Auth and ShinyProxy
- How to Use Shiny Containers with ShinyProxy
- Approximating RStudio Server Pro (and Shiny Server Pro, and JupyterHub) for Free
The team at Appsilon has a five-part series of posts on "Super Solutions for Shiny Architecture" covering:
- Using Session Data
- JavaScript Is Your Friend
- Softcoding Constants in the App
- Using R6 Classes
- Automated Tests
In terms of getting R to play nice with Airflow, the following provide some guidance:
- Executing an R Script from Airflow
- Running R Scripts in Airflow?
- [AIRFLOW-2193] Add ROperator for using R #3115 is a (closed) pull request about this
- Deploying R Models in Production with Apache Airflow and AWS Batch, even though this doesn't mention Shiny
Securing Shiny Apps provides "[a] summary of free/open source ways of securing Shiny."
Two posts on the Auth0 blog cover addtion authentication to Shiny:
- Adding Authentication to Shiny Open Source Edition
- Adding Authentication to Shiny Server in 4 Simple Steps
In terms of password-protection for Shiny apps:
- The
shinymanager
package provides "simple and secure authentication for single Shiny applications," with the encrypted credentials stored in a SQLite database - Password Protect Shiny Apps covers, as one would expect, how to add password protection to your apps.
- Outstanding User Interfaces with Shiny
- Why Is My Dashboard Ugly? A Crash Course in R Shiny UI
shiny.semantic
0.4.0 Update Brings CSS Grid UI Functionality to Shiny Apps- Alternative Design for Shiny
- The Importance of User Experience (with John Coene), episode 10 of the Shiny Developer Series
shinyjqui
shinyWidgets
bslib
"provides tools for creating custom Bootstrap themes, making it easier to style Shiny apps & R Markdown documents directly from R without writing unruly CSS and HTML."- Custom and Dynamic Styles using
bslib
- Using
shinytest
with R Packages - Testing in Depth
- Using
shinytest
with Continuous Integration - Testing Shiny Apps goes into "how one might approach 'testing' a Shiny app" using RSelenium.
- Developing Robust Shiny Apps with Regression Testing
- Load Testing Shiny Applications
- Puppeteer Shiny Test
crrry
- How to Conduct Effective User Tests for Shiny Dashboards
If you need a quickstart guide to Docker, R Docker Tutorial is a (non-Shiny-specific) tutorial on Docker for R users that may be helpful.
DataCamp's EC2 Tutorial for Beginners is a good quickstart if you need some basic training with that service.
- How to User Rocker (R + Docker) to Containerize an Application Consist of Both R and Shiny Python Libraries
- How to Deploy Shiny Server with AWS
- Deploying a Shiny App with Shiny Server on an AWS EC2 Instance
Some familiarty with web development languages will come in handy, especially when utilizing Advanced UI features and shinyjs
.
Colin Fey of {golem}
fame's JavaScript 4 Shiny: Field Notes is a good place to start.
Mozilla's MDN web docs has excellent documentation on these technologies written "by developers, for developers."
Introduction to Data Technologies also has a useful introduction to HTML and CSS.
Other resources worth a read:
- 7 Easy Steps to Custom Inputs in Shiny
- Build Your Entire UI with HTML from the official R Studio Shiny documentation
- HTML Templates from the official R Studio Shiny documentation
- Web Fundamentals, "Google's opinionated reference for building amazing web experiences"
- The Shiny Documents chapter inR Markdown: The Definitive Guide is worth a read.
- Generating Downloadable Reports from the official R Studio Shiny documentation
- Application Layout Guide from the official docs
- R Studio's Gallery of Shiny applications is a great source of ideas and inspiration when designing an app.
- Grid Style Sheets "are a radical approach to doing app-style layouts in a browser. It is a JavaScript library that replaces the browser’s built-in layout engine with one based on a constraint solving algorithm. The result is that some layouts that are incredibly tricky in CSS are completely natural to implement in GSS. This talk will demonstrate an experimental R library that makes it simple for any Shiny developer to take advantage of CSS. 12:56."
- RinteRface, a "collection of outstanding APIs for R Shiny"
Being fluent in R as a programming language (as opposed to a tool and interactive environment for data analysis) goes a long way when building Shiny apps.
The Functional Programming chapters in Hadley Wickham's Advanced R (2nd Edition) are good for learning an approach to R programming that will help you write app code that follows the DRY principle.
- Create a Dynamic Number of UI Elements in Shiny with
purrr
- Generate Custom HTML per Row of a Data Frame with
pmap
- Bang Bang: How to Program with
dplyr
has some stuff on Shiny.
These are good but I haven't decided where to put these yet. Thus, the terrible section name...
- Making Shiny Apps Mobile Friendly
- Shiny Issues, Features, and Best Practices from the RStudio Community
- How California Uses Shiny in Production to Fight COVID-19
tsibbletalk
: Interactive Graphics for Tsibble Objects- The Subtleties of Shiny Reactive Programming:
lapply
andfor
Loops - Shiny Tips: The First Set
reactlog
- 3 Wild-Caught R and Python Applications
- Persistent Data Storage in Shiny Apps
- Shiny Developer Series is a series of webinars that are worth watching.
- How can I insert an image into the navbar on a shiny navbarPage()? answer on Stack Overflow
- In R Shiny, When Is an Error Really an Error?
- Use
shinydashboard
inshiny
shows how to use avalueBox()
in a Shiny app (cf. a Shiny dashboard) via theshinyWidgets::useshinydashboard()
function. - Using Cookie Based Authentication with Shiny
- If you need a WYSIWYG text editor in your app, check out
shinyMCE
. shinyAce
is another text editor option.- Long Running Tasks with Shiny: Challenges and Solutions
- Shiny Database App (CRUD)
- Shiny in Production: App and Database Syncing
- Shiny in Production: Database Transactions
- Exploring
yonder
with Nathan Teetor - Managing App Dependencies in Packages
- Styling Shiny Apps with Sass and Bootstrap 4
- Fetch API Results from the Browser and Send Them to Shiny
chuck
: A Training Tool for Deploying Shiny Apps- Client-Side Interactivity: Do More with Crosstalk
- Creating Interactive Dashboards in R Shiny Using Python Scripts as the Backend
- Reticulated Shiny
- Tutorial: Using Shiny + Reticulate to Create Apps with R and Python 3
- Keep an eye on questions tagged
shiny
on Stack Overflow - Dash with
golem
: First Contact reactable
: An Interactive Tables Guidereactable
Tutorialreactable
Examples- Running Shiny Server with a Proxy
tsibbletalk
dockerstats
- Winners of the 1st Shiny Contest
- 3 Fun Apps for Your Long Labor Day Weekend
- Build Shiny Dashboard with Elasticsearch
- Building an A/B Testing Analytics System with R and Shiny
- Rapid Multi-Language Support for Shiny Apps
- Basic Multipage Routing Tutorial for Shiny Apps:
shiny.router
- Running Compiled Stan Models in Shiny
- Climbing the Ladder of Shiny Mastery with Hadley Wickham
- Mastering Shiny with Appsilon X-Session Recordings
- Database Basics:
dbplyr
andDBI