Shiny App-Packages

Getting your app into an R package

Author

Martin Frigaard

Published

2025-01-31

Welcome!



Develop your Shiny application as an R package.


Shiny combines the power of R’s statistical capabilities with the interactivity of a web-based application.

R packages are collections of pre-built, self-contained code, data, and documentation designed to perform operations or accomplish tasks beyond the capabilities of the R language.

What’s in the book

This book is a resource to help ‘connect the dots’ between building scalable Shiny applications and writing R packages. Adopting R package development practices in the early stages of your Shiny app will improve the reusability, maintainability, and shareability of all your hard work.

The code and data originate from the excellent Building Web Applications with Shiny (BWAS) course. If you’re new to Shiny development this course is a great place to start. The four learning modules will provide a solid understanding for many of the topics covered in this book.

This resource is currently being revised to include recent changes in the Shiny development landscape (Positron, AI tools, etc.). While most of the information in the ‘Introduction’ and ‘App-packages’ sections will remain unchanged, some sections are being written/updated:

  1. Debugging
  2. Testing
  3. Deployment
  4. Frameworks

Thank you for your patience!

What’s not in the book

This book isn’t a replacement for Mastering Shiny or R Packages, 2ed (or Writing R Extensions). I highly suggest bookmarking these resources to return and read when you’d like to learn more about R package and Shiny development.

I also won’t be recommending a particular Shiny framework or package, but I’ll cover a few popular choices, show what they’re doing ‘under the hood,’ and let you decide if you’d like to adopt their practices.

LLM Disclaimer: Am I a robot?

Given the current landscape of online resources and the impressive capabilities of large language models (LLMs), I feel it’s important to clarify the authorship of this book.

Only the code included in this book was created with the assistance of LLMs, and this applies only to specific chapters that are explicitly noted. I have fully authored the narrative, commentary, and explanations. Hopefully, the typos and/or grammatical errors serve as a signature of authenticity.

What I assume about you

If you’re reading this, I assume you’re comfortable with R, Posit Workbench, Shiny, and the tidyverse. Maybe you haven’t built a ton of applications, but you understand reactivity, and you’re comfortable with the core Shiny concepts (i.e., the UI, server, *_Input(), *_Output(), and render_* functions, etc.).

Code examples

The code files for each chapter are stored in GitHub repository. Major code changes are stored in branches. Whenever a new branch is used, you’ll see the Git Branch icon with a link to the repo/branch in the margin.

See the <branch> branch of sap.

In an effort to make the code and examples more accessible and easy to use, I’ve also created the shinypak package. This package can be used to launch or download the applications in each branch.1

Example:

# install.packages('pak')
pak::pak('mjfrigaard/shinypak')
shinypak::launch('02.3_proj-app')


  1. shinypak uses the .Rproj files to launch apps, so a an installation of RStudio is required. However, the applications in each branch still be downloaded with shinypak::get().↩︎