0%

Master the Shiny web framework—and take your R skills to a whole new level. By letting you move beyond static reports, Shiny helps you create fully interactive web apps for data analyses. Users will be able to jump between datasets, explore different subsets or facets of the data, run models with parameter values of their choosing, customize visualizations, and much more.

Hadley Wickham from RStudio shows data scientists, data analysts, statisticians, and scientific researchers with no knowledge of HTML, CSS, or JavaScript how to create rich web apps from R. This in-depth guide provides a learning path that you can follow with confidence, as you go from a Shiny beginner to an expert developer who can write large, complex apps that are maintainable and performant.

  • Get started: Discover how the major pieces of a Shiny app fit together
  • Put Shiny in action: Explore Shiny functionality with a focus on code samples, example apps, and useful techniques
  • Master reactivity: Go deep into the theory and practice of reactive programming and examine reactive graph components
  • Apply best practices: Examine useful techniques for making your Shiny apps work well in production

Table of Contents

  1. Preface
    1. What Is Shiny?
    2. Who Should Read This Book?
    3. What Will You Learn?
    4. What Won’t You Learn?
    5. Prerequisites
    6. Conventions Used in This Book
    7. Using Code Examples
    8. O’Reilly Online Learning
    9. How to Contact Us
    10. Acknowledgments
    11. How This Book Was Built
  2. I. Getting Started
  3. 1. Your First Shiny App
    1. Introduction
    2. Create App Directory and File
    3. Running and Stopping
    4. Adding UI Controls
    5. Adding Behavior
    6. Reducing Duplication with Reactive Expressions
    7. Summary
    8. Exercises
  4. 2. Basic UI
    1. Introduction
    2. Inputs
    3. Common Structure
    4. Free Text
    5. Numeric Inputs
    6. Dates
    7. Limited Choices
    8. File Uploads
    9. Action Buttons
    10. Exercises
    11. Outputs
    12. Text
    13. Tables
    14. Plots
    15. Downloads
    16. Exercises
    17. Summary
  5. 3. Basic Reactivity
    1. Introduction
    2. The Server Function
    3. Input
    4. Output
    5. Reactive Programming
    6. Imperative Versus Declarative Programming
    7. Laziness
    8. The Reactive Graph
    9. Reactive Expressions
    10. Execution Order
    11. Exercises
    12. Reactive Expressions
    13. The Motivation
    14. The App
    15. The Reactive Graph
    16. Simplifying the Graph
    17. Why Do We Need Reactive Expressions?
    18. Controlling Timing of Evaluation
    19. Timed Invalidation
    20. On Click
    21. Observers
    22. Summary
  6. 4. Case Study: ER Injuries
    1. Introduction
    2. The Data
    3. Exploration
    4. Prototype
    5. Polish Tables
    6. Rate Versus Count
    7. Narrative
    8. Exercises
    9. Summary
  7. II. Shiny in Action
  8. 5. Workflow
    1. Development Workflow
    2. Creating the App
    3. Seeing Your Changes
    4. Controlling the View
    5. Debugging
    6. Reading Tracebacks
    7. Tracebacks in Shiny
    8. The Interactive Debugger
    9. Case Study
    10. Debugging Reactivity
    11. Getting Help
    12. Reprex Basics
    13. Making a Reprex
    14. Making a Minimal Reprex
    15. Case Study
    16. Summary
  9. 6. Layout, Themes, HTML
    1. Introduction
    2. Single-Page Layouts
    3. Page Functions
    4. Page with Sidebar
    5. Multirow
    6. Exercises
    7. Multipage Layouts
    8. Tabsets
    9. Navlists and Navbars
    10. Bootstrap
    11. Themes
    12. Getting Started
    13. Shiny Themes
    14. Plot Themes
    15. Exercises
    16. Under the Hood
    17. Summary
  10. 7. Graphics
    1. Interactivity
    2. Basics
    3. Clicking
    4. Other Point Events
    5. Brushing
    6. Modifying the Plot
    7. Interactivity Limitations
    8. Dynamic Height and Width
    9. Images
    10. Summary
  11. 8. User Feedback
    1. Validation
    2. Validating Input
    3. Canceling Execution with req()
    4. req() and Validation
    5. Validate Output
    6. Notifications
    7. Transient Notification
    8. Removing on Completion
    9. Progressive Updates
    10. Progress Bars
    11. Shiny
    12. Waiter
    13. Spinners
    14. Confirming and Undoing
    15. Explicit Confirmation
    16. Undoing an Action
    17. Trash
    18. Summary
  12. 9. Uploads and Downloads
    1. Upload
    2. UI
    3. Server
    4. Uploading Data
    5. Download
    6. Basics
    7. Downloading Data
    8. Downloading Reports
    9. Case Study
    10. Exercises
    11. Summary
  13. 10. Dynamic UI
    1. Updating Inputs
    2. Simple Uses
    3. Hierarchical Select Boxes
    4. Freezing Reactive Inputs
    5. Circular References
    6. Interrelated Inputs
    7. Exercises
    8. Dynamic Visibility
    9. Conditional UI
    10. Wizard Interface
    11. Exercises
    12. Creating UI with Code
    13. Getting Started
    14. Multiple Controls
    15. Dynamic Filtering
    16. Dialog Boxes
    17. Exercises
    18. Summary
  14. 11. Bookmarking
    1. Basic Idea
    2. Updating the URL
    3. Storing Richer State
    4. Bookmarking Challenges
    5. Exercises
    6. Summary
  15. 12. Tidy Evaluation
    1. Motivation
    2. Data-Masking
    3. Getting Started
    4. Example: ggplot2
    5. Example: dplyr
    6. User-Supplied Data
    7. Why Not Use Base R?
    8. Tidy-Selection
    9. Indirection
    10. Tidy-Selection and Data-Masking
    11. parse() and eval()
    12. Summary
  16. III. Mastering Reactivity
  17. 13. Why Reactivity?
    1. Introduction
    2. Why Do We Need Reactive Programming?
    3. Why Can’t You Use Variables?
    4. What About Functions?
    5. Event-Driven Programming
    6. Reactive Programming
    7. A Brief History of Reactive Programming
    8. Summary
  18. 14. The Reactive Graph
    1. Introduction
    2. A Step-by-Step Tour of Reactive Execution
    3. A Session Begins
    4. Execution Begins
    5. Reading a Reactive Expression
    6. Reading an Input
    7. Reactive Expression Completes
    8. Output Completes
    9. The Next Output Executes
    10. Execution Completes, Outputs Flushed
    11. An Input Changes
    12. Invalidating the Inputs
    13. Notifying Dependencies
    14. Removing Relationships
    15. Re-execution
    16. Exercises
    17. Dynamism
    18. The Reactlog Package
    19. Summary
  19. 15. Reactive Building Blocks
    1. Reactive Values
    2. Exercises
    3. Reactive Expressions
    4. Errors
    5. on.exit()
    6. Exercises
    7. Observers and Outputs
    8. Isolating Code
    9. isolate()
    10. observeEvent() and eventReactive()
    11. Exercises
    12. Timed Invalidation
    13. Polling
    14. Long-Running Reactives
    15. Timer Accuracy
    16. Exercises
    17. Summary
  20. 16. Escaping the Graph
    1. Introduction
    2. What Doesn’t the Reactive Graph Capture?
    3. Case Studies
    4. One Output Modified by Multiple Inputs
    5. Accumulating Inputs
    6. Pausing Animations
    7. Exercises
    8. Antipatterns
    9. Summary
  21. IV. Best Practices
  22. 17. General Guidelines
    1. Introduction
    2. Code Organization
    3. Testing
    4. Dependency Management
    5. Source Code Management
    6. Continuous Integration/Deployment
    7. Code Reviews
    8. Summary
  23. 18. Functions
    1. File Organization
    2. UI Functions
    3. Other Applications
    4. Functional Programming
    5. UI as Data
    6. Server Functions
    7. Reading Uploaded Data
    8. Internal Functions
    9. Summary
  24. 19. Shiny Modules
    1. Motivation
    2. Module Basics
    3. Module UI
    4. Module Server
    5. Updated App
    6. Namespacing
    7. Naming Conventions
    8. Exercises
    9. Inputs and Outputs
    10. Getting Started: UI Input and Server Output
    11. Case Study: Selecting a Numeric Variable
    12. Server Inputs
    13. Modules Inside of Modules
    14. Case Study: Histogram
    15. Multiple Outputs
    16. Exercises
    17. Case Studies
    18. Limited Selection and Other
    19. Wizard
    20. Dynamic UI
    21. Single Object Modules
    22. Summary
  25. 20. Packages
    1. Converting an Existing App
    2. Single File
    3. Module Files
    4. A Package
    5. Benefits
    6. Workflow
    7. Sharing
    8. Extra Steps
    9. Deploying Your App-Package
    10. R CMD check
    11. Summary
  26. 21. Testing
    1. Testing Functions
    2. Basic Structure
    3. Basic Workflow
    4. Key Expectations
    5. User Interface Functions
    6. Workflow
    7. Code Coverage
    8. Keyboard Shortcuts
    9. Workflow Summary
    10. Testing Reactivity
    11. Modules
    12. Limitations
    13. Testing JavaScript
    14. Basic Operation
    15. Case Study
    16. Testing Visuals
    17. Philosophy
    18. When Should You Write Tests?
    19. Summary
  27. 22. Security
    1. Data
    2. Compute Resources
  28. 23. Performance
    1. Dining at Restaurant Shiny
    2. Benchmark
    3. Recording
    4. Replay
    5. Analysis
    6. Profiling
    7. The Flame Graph
    8. Profiling R Code
    9. Profiling a Shiny App
    10. Limitations
    11. Improve Performance
    12. Caching
    13. Basics
    14. Caching a Reactive
    15. Caching Plots
    16. Cache Key
    17. Cache Scope
    18. Other Optimizations
    19. Schedule Data Munging
    20. Manage User Expectations
    21. Summary
  29. Index
3.142.197.212