10:00
posit::conf(2023)
Shiny in Production: Tools & Techniques
… at least for production-quality apps!
app.RPrototype apps can coast by with a single app.R
app.R almost explodesR DirectoryR directory{golem}Opinionated framework for building production-grade Shiny applications as R packages
{usethis} & {devtools}├── DESCRIPTION
├── NAMESPACE
├── R
│ ├── app_config.R
│ ├── app_server.R
│ ├── app_ui.R
│ └── run_app.R
├── dev
│ ├── 01_start.R
│ ├── 02_dev.R
│ ├── 03_deploy.R
│ └── run_dev.R
├── inst
│ ├── app
│ │ └── www
│ │ └── favicon.ico
│ └── golem-config.yml
└── man
└── run_app.Rd
Use helper functions in dev/01_start.R to…
DESCRIPTION, README, LICENSE (etc.) filesUse the helper functions in dev/02_dev.R to…
And use dev/run_dev.R to run your app
Use the helper functions in dev/03_deploy.R to…
devtools::check() )R CMD build mypackage )mod_picker.R
Minimal changes necessary
🤔 id
moduleServer(): Encapsulate server-side logic with namespace applied.
mod_picker.R
tagList() of inputs, output placeholders, and other UI elementsmod_picker.R
Input & return values can be a mix of static and reactive objects
sets_rvsets_rv()set_selection, set_selection()Add a new Shiny module to pick LEGO set themes
Create a new Shiny module with LEGO data metrics!
10:00
Imagine your application is working great!
ggplot2 version 0.9.3
ggplot2 version 1.0.0
{renv}Create reproducible environments for your R projects.
{packrat}Upon initializing a project:
.Rprofile to activate custom package library on startuprenv.lock to describe state of project libraryrenv/library to hold private project libraryrenv/activate.R performs activationSticking with {renv} will pay off (trust me)