Shiny App-Packages

Getting your app into an R package


Martin Frigaard


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.

For continuity, I’ve used code and data from the excellent Building Web Applications with Shiny (BWAS) course. The learning modules in BWAS also serve as ‘prerequisites’ for many of the chapters covered here (if you haven’t completed that course, be sure you understand the topics it covers). You’ll find each section in this book also includes a dedicated GitHub repository and branch for you to follow along.

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 those resources to return and read when you’d like to learn more about package 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.

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 repositories. 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 moviesApp.

In an effort to make the code and examples more accessible and easy to use, I’ve also created the shinypak package:


# install.packages('pak')