• Mastering Shiny Book Club
  • Welcome
    • Pace
    • Format
  • Preface
  • I Getting started
  • 1 Your first Shiny app
    • 1.1 Introduction
      • 1.1.1 If you haven’t installed Shiny already:
    • 1.2 Creating an app
    • 1.3 Running and stopping the app
      • 1.3.1 Running the app
      • 1.3.2 Stopping the app:
    • 1.4 Adding UI controls
    • 1.5 Adding behaviour
    • 1.6 Reactive expressions
    • 1.7 Visualising reactive expressions
    • 1.8 Shiny resources
      • 1.8.1 Other resources
    • 1.9 Meeting Videos
      • 1.9.1 Cohort 1
      • 1.9.2 Cohort 2
      • 1.9.3 Cohort 3
      • 1.9.4 Cohort 4
      • 1.9.5 Cohort 5
  • 2 Basic UI
    • 2.1 FYI
    • 2.2 The Shiny Basic User Interface (ui)
    • 2.3 What Can One INPUT?
    • 2.4 Input 1 - Text & Numeric
    • 2.5 Inputs 2 - Dates, Limited choices, File uploads, Action buttons
    • 2.6 What can one OUTPUT?
      • Text
    • 2.7 Outputs 2 - Tables
    • 2.8 Outputs 3 - Plots, Downloads
    • 2.9 Layouts
    • 2.10 Under the hood
    • 2.11 Other tools & material
    • 2.12 Summary
    • 2.13 Meeting Videos
      • 2.13.1 Cohort 1
      • 2.13.2 Cohort 2
      • 2.13.3 Cohort 3
      • 2.13.4 Cohort 4
      • 2.13.5 Cohort 5
  • 3 Basic Reactivity
    • 3.1 Recap
      • 3.1.1 Important Learnings so far, main app components:
    • 3.2 A deeper dive into the server function
    • 3.3 Reactive Programming
      • 3.3.1 Imperative vs declarative programming
    • 3.4 Laziness
      • 3.4.1 Will this app work?
    • 3.5 The reactive graph
    • 3.6 Reactive expressions
    • 3.7 New vocab - producers and consumers
    • 3.8 Execution order
    • 3.9 Controlling timing of evaluation
      • 3.9.1 Timed invalidation
      • 3.9.2 On click
    • 3.10 Observers
      • 3.10.1 When might you use an observer?
    • 3.11 Acknowledgements
    • 3.12 Meeting Videos
      • 3.12.1 Cohort 1
      • 3.12.2 Cohort 2
      • 3.12.3 Cohort 3
      • 3.12.4 Cohort 4
      • 3.12.5 Cohort 5
  • 4 Case study: ER injuries
    • 4.1 Introduction
    • 4.2 The data
    • 4.3 Exploration
      • 4.3.1 Facet Wrap
    • 4.4 Prototype
    • 4.5 Polish tables
      • 4.5.1 Exercise 4.8.2
      • 4.5.2 Hadley’s Fix
    • 4.6 Rate vs count
    • 4.7 Narrative
    • 4.8 Exercises
    • 4.9 DSLC Customs
      • 4.9.1 UI
      • 4.9.2 Server
    • 4.10 Meeting Videos
      • 4.10.1 Cohort 1
      • 4.10.2 Cohort 2
      • 4.10.3 Cohort 3
      • 4.10.4 Cohort 4
      • 4.10.5 Cohort 5
  • II Shiny in action
  • 5 Workflow
    • 5.1 Why workflow?
    • 5.2 Learning objectives
    • 5.3 Development workflow
    • 5.4 Creating apps
    • 5.5 Seeing your changes faster
    • 5.6 Controlling the view
    • 5.7 Debugging
    • 5.8 Three dubugging Challenges
      • 5.8.1 You get an unexpected error (easiest case).
      • 5.8.2 You don’t get any errors
      • 5.8.3 All the values are correct, but they’re not updated when you expect
    • 5.9 Fixing errors: Tracebacks
      • 5.9.1 Example of reading traceback
    • 5.10 Tracebacks in Shiny
    • 5.11 Three components to a Shiny error stack
    • 5.12 Fixing errors: Interactive debugger
      • 5.12.1 Useful interactive debugger commands
    • 5.13 Debugging reactivity
    • 5.14 Getting help (using Reprex)
      • 5.14.1 How to make a reprex
      • 5.14.2 Making a minimal reprex
    • 5.15 Meeting Videos
      • 5.15.1 Cohort 1
      • 5.15.2 Cohort 2
      • 5.15.3 Cohort 3
      • 5.15.4 Cohort 4
      • 5.15.5 Cohort 5
  • 6 Layout, themes, HTML
    • 6.1 Disclaimer
    • 6.2 Learning objectives
    • 6.3 Resources
      • 6.3.1 Websites
      • 6.3.2 Books
      • 6.3.3 Packages / Tools
    • 6.4 Under the hood
      • 6.4.1 HTML - Hypertext markup language
      • 6.4.2 Writing HTML with shiny / htmltools
      • 6.4.3 CSS - Cascading Style Sheets
      • 6.4.4 Using CSS to style a shiny app
    • 6.5 Bootstrap & Themes
    • 6.6 Layouts
      • 6.6.1 Single-page Layouts
      • 6.6.2 Multi-page Layouts
    • 6.7 Case study
      • 6.7.1 The initial app (app-01.R)
      • 6.7.2 The final app (app.R)
    • 6.8 Meeting Videos
      • 6.8.1 Cohort 1
      • 6.8.2 Cohort 2
      • 6.8.3 Cohort 3
      • 6.8.4 Cohort 4
      • 6.8.5 Cohort 5
  • 7 Graphics
    • 7.1 Interactivity: the basics
      • 7.1.1 Summary of interactive action events
    • 7.2 Modifying the plot
    • 7.3 Interactivity limitations
    • 7.4 Dynamic height and width
    • 7.5 Images
    • 7.6 Resources
    • 7.7 Presentation Cohort 1
    • 7.8 Meeting Videos
      • 7.8.1 Cohort 1
      • 7.8.2 Cohort 2
      • 7.8.3 Cohort 3
      • 7.8.4 Cohort 4
      • 7.8.5 Cohort 5
  • 8 User Feedback
    • 8.1 Validation
      • 8.1.1 Validating input
      • 8.1.2 Cancelling execution with req()
      • 8.1.3 req() and validation
      • 8.1.4 Validate output
    • 8.2 Notifications
      • 8.2.1 Transient notifications
      • 8.2.2 Removing on completion
      • 8.2.3 Progressive updates
    • 8.3 Progress bars
      • 8.3.1 Shiny
      • 8.3.2 Waiter
      • 8.3.3 Spinners
    • 8.4 Confirming and undoing
      • 8.4.1 Explicit confirmation
      • 8.4.2 Undoing an action
    • 8.5 Meeting Videos
      • 8.5.1 Cohort 1
      • 8.5.2 Cohort 2
      • 8.5.3 Cohort 3
      • 8.5.4 Cohort 4
      • 8.5.5 Cohort 5
  • 9 Uploads and Downloads
    • 9.1 File uploads
      • 9.1.1 UI
      • 9.1.2 Server
    • 9.2 Uploading data
      • 9.2.1 Observe this in action
      • 9.2.2 Use a break-point to observe what’s going on here
    • 9.3 Downloads
      • 9.3.1 UI
      • 9.3.2 Server
    • 9.4 Downloading data
      • 9.4.1 Observe this in action
    • 9.5 Downloading reports
      • 9.5.1 Observe this in action
      • 9.5.2 Some tips & tricks when including report download functionality:
    • 9.6 Meeting Videos
      • 9.6.1 Cohort 1
      • 9.6.2 Cohort 2
      • 9.6.3 Cohort 3
      • 9.6.4 Cohort 4
      • 9.6.5 Cohort 5
  • 10 Dynamic UI
    • 10.1 Introduction
    • 10.2 Updating inputs
      • 10.2.1 Update functions
    • 10.3 Dynamic visibility
    • 10.4 Creating UI with code
    • 10.5 Conclusions
    • 10.6 Meeting Videos
      • 10.6.1 Cohort 1
      • 10.6.2 Cohort 2
      • 10.6.3 Cohort 3
      • 10.6.4 Cohort 4
      • 10.6.5 Cohort 5
  • 11 Bookmarking
    • 11.1 Introduction
    • 11.2 Example: Lissajous Curves
    • 11.3 Modifying App
    • 11.4 Prototype App
    • 11.5 Breaking down the URL
    • 11.6 Updating the URL
    • 11.7 Refined App
    • 11.8 Storing a richer state
    • 11.9 Bookmarking Challenges
    • 11.10 Meeting Videos
      • 11.10.1 Cohort 1
      • 11.10.2 Cohort 2
      • 11.10.3 Cohort 3
      • 11.10.4 Cohort 4
      • 11.10.5 Cohort 5
  • 12 Tidy evaluation
    • 12.1 Tidy Evaluation
    • 12.2 Motivation
    • 12.3 Data-masking
      • 12.3.1 Getting Started
      • 12.3.2 Example: ggplot2
      • 12.3.3 Example: dplyr
      • 12.3.4 User supplied data
      • 12.3.5 Why not use base R?
    • 12.4 Tidy-selection
      • 12.4.1 Indirection
      • 12.4.2 Tidy Selection and Data Masking
    • 12.5 Meeting Videos
      • 12.5.1 Cohort 1
      • 12.5.2 Cohort 2
      • 12.5.3 Cohort 3
      • 12.5.4 Cohort 4
      • 12.5.5 Cohort 5
  • III Mastering reactivity
  • 13 Why reactivity?
    • Shiny is good magic
    • What is reactive programming?
    • Why reactive programming in Shiny?
    • Why can’t you use variables?
    • Why can’t you use functions?
    • Event-driven programming
    • Event-driven limitation
    • Reactive programming
    • Properties of reactive expressions
    • History of reactive programming
    • 13.1 Meeting Videos
      • 13.1.1 Cohort 1
      • 13.1.2 Cohort 2
      • 13.1.3 Cohort 3
      • 13.1.4 Cohort 4
      • 13.1.5 Cohort 5
  • 14 The reactive graph
    • Quick review of chapter 3 Basic reactivity
    • Reactive execution example (code)
    • Reactive execution example (graphic)
    • A session begins
    • Execution begins
    • Reading a reactive expression
    • Reading an input
    • Reactive expression completes
    • Output completes
    • The next output executes
    • Outputs flushed
    • An input changes (1/3)
    • An input changes (2/3)
    • An input changes (3/3)
    • Rediscovering the relationships
    • Re-execution
    • Exercises
    • Exercises
    • Exercises
    • Dynamism
    • Dynamism
    • Dynamism
    • Dynamism
    • The reactlog package
    • Summary
    • 14.1 Meeting Videos
      • 14.1.1 Cohort 1
      • 14.1.2 Cohort 2
      • 14.1.3 Cohort 3
      • 14.1.4 Cohort 4
      • 14.1.5 Cohort 5
  • 15 Reactive Building Blocks
    • Types of Reactive Values
    • Copy-on-modify Semantics
    • Copy-on-modify Semantics
    • Copy-on-modify Semantics
    • Copy-on-modify Semantics
    • Reference Semantics (shiny)
    • Reference Semantics (R6)
    • Reference Semantics (R6)
    • Reference Semantics (R6)
    • Exercises
    • Exercises
    • Reactive Expressions: Cached Errors
    • Reactive Expressions: Propagated Errors
    • Reactive Expressions: Errors seq()
    • Where does on.exit() work?
    • Applications of on.exit()
    • Observers and Outputs
    • Observers and Outputs
    • observe() Function
    • observe() Propertites
    • Isolating Code
    • Using the isolate Function
    • Using the observeEvent Function
    • observeEvent and eventReactive arguments
    • Review to reactiveTimer()
    • Understanding invalidateLater(ms)
    • Understanding invalidateLater(ms)
    • Understanding invalidateLater(ms)
    • Importing data
    • Long running reactives
    • Timer accuracy
    • 15.1 Meeting Videos
      • 15.1.1 Cohort 1
      • 15.1.2 Cohort 2
      • 15.1.3 Cohort 3
      • 15.1.4 Cohort 4
      • 15.1.5 Cohort 5
  • 16 Escaping the graph
    • 16.1 Introduction
    • 16.2 Combine reactive values
    • 16.3 Connect the right side with the left side
      • 16.3.1 Case Studies:
    • 16.4 Create infinite loops
    • 16.5 Conclusions
      • 16.5.1 Resources:
    • 16.6 Meeting Videos
      • 16.6.1 Cohort 1
      • 16.6.2 Cohort 2
      • 16.6.3 Cohort 3
      • 16.6.4 Cohort 4
      • 16.6.5 Cohort 5
  • IV Best practices
  • 17 General guidelines
    • 17.1 “Best practices” section of the book
    • 17.2 Software engineering
    • 17.3 Code organization
    • 17.4 Testing
    • 17.5 Dependency management
    • 17.6 Source code management
    • 17.7 Continuous integration / Continuous deployment
    • 17.8 Code reviews
    • 17.9 Meeting Videos
      • 17.9.1 Cohort 1
      • 17.9.2 Cohort 2
      • 17.9.3 Cohort 3
      • 17.9.4 Cohort 4
      • 17.9.5 Cohort 5
  • 18 Functions
    • 18.1 File Organization
    • 18.2 UI Functions
      • 18.2.1 Functional Programming
      • 18.2.2 UI as data
    • 18.3 Server Functions
      • 18.3.1 Internal functions
    • 18.4 Meeting Videos
      • 18.4.1 Cohort 1
      • 18.4.2 Cohort 2
      • 18.4.3 Cohort 3
      • 18.4.4 Cohort 4
      • 18.4.5 Cohort 5
  • 19 Shiny modules
    • Without modules
    • Modules benefits
    • After implementing modules
    • App 1: Before applying modules
    • App 1: UI function
    • App 1: UI using NS once
    • App 1: Module server
    • App 1: Module app
    • App 1: Module app (Shinylive)
    • Modules isolation
    • Modules conventions
    • Group 1: Exercise 1
    • Group 1: Exercise 2
    • Group 1: Exercise 2
    • Group 1: Exercise 3
    • Group 1: Exercise 3
    • Group 1: Exercise 3 (Shinylive)
    • Group 1: Exercise 3
    • Group 1: Exercise 3
    • Group 1: Exercise 3 (Shinylive)
    • Inputs and outputs
    • App 2: Select data (UI)
    • App 2: Select data (SERVER)
    • App 2: Select data (APP)
    • App 2: Select data (Shinylive)
    • App 2: Extracting a numeric variable (UI)
    • App 2: Extracting a numeric variable (SERVER)
    • App 2: Extracting a numeric variable (APP)
    • App 2: Extracting a numeric variable (Shinylive)
    • Tip: Validate if reactive
    • Tip: Validate if reactive
    • Tip: Validate the input of each argument
    • App 3: Modules consolidation (UI)
    • App 3: Modules consolidation (SERVER)
    • App 3: Modules consolidation (APP)
    • App 3: Modules consolidation (Shinylive)
    • Tip: Modules challenge
    • App 4: Bind and Histogram (UI)
    • App 4: Bind and Histogram (SERVER)
    • App 4: Reusing modules (APP)
    • App 4: Reusing modules (Shinylive)
    • Tip: Spitting Module UI
    • Tip: Spitting Module UI
    • Tip: Spitting Module UI (Shinylive)
    • Tip: Multiple output (SERVER)
    • Tip: Multiple output (APP)
    • Tip: Multiple output (APP)
    • Tip: Multiple output (Shinylive)
    • Group 2: Exercise 1
    • Group 2: Exercise 1 (UI)
    • Group 2: Exercise 1 (Server)
    • Group 2: Exercise 1 (Server)
    • Group 2: Exercise 1 (Shinylive)
    • Group 2: Exercise 2
    • Group 2: Exercise 2 (App)
    • Group 2: Exercise 2 (Shinylive)
    • Group 2: Exercise 3
    • Group 2: Exercise 3 (Server)
    • Group 2: Exercise 3 (App)
    • Group 2: Exercise 3 (Shinylive)
    • Links to examples
    • Meeting Videos
      • 19.0.1 Cohort 1
      • 19.0.2 Cohort 2
      • 19.0.3 Cohort 3
      • 19.0.4 Cohort 4
      • 19.0.5 Cohort 5
  • 20 Packages
    • 20.1 Package Structure
    • 20.2 Benefits
    • 20.3 Converting an existing app
    • 20.4 Example: shinysurveys
      • 20.4.1 Installation
      • 20.4.2 Demo
      • 20.4.3 Let’s take a look!
    • 20.5 Meeting Videos
      • 20.5.1 Cohort 1
      • 20.5.2 Cohort 3
      • 20.5.3 Cohort 4
      • 20.5.4 Cohort 5
  • 21 Testing
    • Purpose of Automated Testing
    • Four levels of testing for shiny apps
    • Testing Basic structure
    • load_file example
    • load_file example
    • load_file example
    • Ways to run tests
    • Confirming test coverage
    • Confirming test coverage
    • expect_equal
    • Relaxed expect_equal
    • expect_error
    • expect_snapshot for UI functions
    • expect_snapshot for UI functions
    • expect_snapshot for UI functions
    • expect_snapshot for UI functions
    • Testing reactivity
    • Testing reactivity: Initial value
    • Testing reactivity: setInputs method
    • Testing reactivity: Modules
    • Testing reactivity: returned method
    • Testing reactivity: Simulated time
    • Testing reactivity: elapse method
    • Testing reactivity: Render outputs
    • Testing reactivity: flushReact method
    • testServer limitations
    • Testing JavaScript
    • Example with observeEvent (shinylive)
    • Example with observeEvent
    • Headless interaction
    • Testing headless interaction
    • Example with updateRadioButtons (shinylive)
    • Example with updateRadioButtons
    • Testing without UI
    • Testing without UI
    • Testing with UI
    • Testing visuals
    • When should you write tests?
    • Other interesting things
    • 21.1 Meeting Videos
      • 21.1.1 Cohort 1
      • 21.1.2 Cohort 2
      • 21.1.3 Cohort 3
      • 21.1.4 Cohort 4
      • 21.1.5 Cohort 5
  • 22 Security
    • 22.1 Introduction
    • 22.2 The security within your app
    • 22.3 Compute resources
    • 22.4 Publishing on shinyapps.io
    • 22.5 Conclusions:
      • 22.5.1 Resources:
    • 22.6 Meeting Videos
      • 22.6.1 Cohort 1
      • 22.6.2 Cohort 2
      • 22.6.3 Cohort 3
      • 22.6.4 Cohort 4
      • 22.6.5 Cohort 5
  • 23 Performance
    • Dining at restaurant Shiny
    • Making your chef more efficient
    • Solving kitchen limitations
    • Benchmarking
    • Benchmarking: Recording
    • Benchmarking: Replay
    • Benchmarking: Analysis
    • Benchmarking: Analysis report
    • Audit Google Lighthouse: Start
    • Audit Google Lighthouse: Results
    • Profiling: Example function
    • Profiling: Example diagram
    • Profiling: R code
    • Profiling: Shiny App
    • Profiling: Limitations
    • Profiling: shiny.tictoc
    • Profiling: shiny.tictoc results
    • Improve performance
    • Improve performance: Caching
    • bindCache(): Basics
    • bindCache(): web API
    • bindCache(): web API
    • bindCache(): web API
    • bindCache(): web API
    • bindCache(): Plots
    • bindCache(): reactive inputs
    • bindCache(): Default cache scope
    • bindCache(): Extending cache scope
    • Other Optimisations: Data munging
    • Other Optimisations: Data munging
    • Other Optimisations: User expectations
    • Resources
    • Meeting Videos
      • 23.0.1 Cohort 1
      • 23.0.2 Cohort 2
      • 23.0.3 Cohort 3
      • 23.0.4 Cohort 4
      • 23.0.5 Cohort 5
  • V Other topics
  • 24 Wrap up session
    • 24.1 Meeting Videos
      • 24.1.1 Cohort 1
  • 25 Up and running with git
    • 25.1 What is git?
    • 25.2 Accessing and using git
    • 25.3 Example using the built in RStudio git GUI.
    • 25.4 Example using git in a system terminal
      • 25.4.1 Example using git in RStudio’s terminal
    • 25.5 What is GitHub?
      • 25.5.1 Other services like GitHub
    • 25.6 A basic workflow - pull, commit, and push
    • 25.7 Personal repo workflow step-by-step
    • 25.8 Personal repo workflow alternative view
    • 25.9 Fork, clone, push, and pull workflow (collaboration)
      • 25.9.1 Some notes about these workflows
    • 25.10 Workflow commands
      • 25.10.1 Get Remote Repo/Update Local Repo
      • 25.10.2 View info about local files
      • 25.10.3 Stage and document changes
      • 25.10.4 Push changes to remote repository
    • 25.11 Demo of the workflow
    • 25.12 Other resources to learn more about git
    • 25.13 Meeting Videos
      • 25.13.1 Cohort 2
  • Published with bookdown

Mastering Shiny Book Club

Links to examples

Two versions of a simple app based on Tidy Tuesday data:

  • Shiny dashboard
  • golem with modules

Examples provided in the 2024 Shiny Conference:

  • https://github.com/deepshamenghani/Demystifying_Shiny_modules
  • https://github.com/hypebright/shinyconf2024-shiny101