Muutke küpsiste eelistusi

Engineering Production-Grade Shiny Apps [Pehme köide]

  • Formaat: Paperback / softback, 364 pages, kõrgus x laius: 234x156 mm, kaal: 680 g, 58 Halftones, color; 58 Illustrations, color
  • Sari: Chapman & Hall/CRC The R Series
  • Ilmumisaeg: 29-Sep-2021
  • Kirjastus: Chapman & Hall/CRC
  • ISBN-10: 0367466023
  • ISBN-13: 9780367466022
  • Formaat: Paperback / softback, 364 pages, kõrgus x laius: 234x156 mm, kaal: 680 g, 58 Halftones, color; 58 Illustrations, color
  • Sari: Chapman & Hall/CRC The R Series
  • Ilmumisaeg: 29-Sep-2021
  • Kirjastus: Chapman & Hall/CRC
  • ISBN-10: 0367466023
  • ISBN-13: 9780367466022
From the Reviews

"[ This book] contains an excellent blend of both Shiny-specific topics and practical advice from software development that fits in nicely with Shiny apps. You will find many nuggets of wisdom sprinkled throughout these chapters."

Eric Nantz, Host of the R-Podcast and the Shiny Developer Series (from the Foreword)

"[ This] book is a gradual and pleasant invitation to the production-ready shiny apps world. It exposes a comprehensive and robust workflow powered by the {golem} package. [ It] fills the not yet covered gap between shiny app development and deployment in such a thrilling way that it may be read in one sitting. In the industry world, where processes robustness is a key toward productivity, this book will indubitably have a tremendous impact."

David Granjon, Sr. Expert Data Science, Novartis

Presented in full color, Engineering Production-Grade Shiny Apps helps people build production-grade shiny applications, by providing advice, tools, and a methodology to work on web applications with R. This book starts with an overview of the challenges which arise from any big web application project: organizing work, thinking about the user interface, the challenges of teamwork and the production environment. Then, it moves to a step-by-step methodology that goes from the idea to the end application. Each part of this process will cover in detail a series of tools and methods to use while building production-ready shiny applications. Finally, the book will end with a series of approaches and advice about optimizations for production.

Features















Focused on practical matters: This book does not cover Shiny concepts, but practical tools and methodologies to use for production.





Based on experience: This book is a formalization of several years of experience building Shiny applications.





Original content: This book presents new methodologies and tooling, not just a review of what already exists.





Engineering Production-Grade Shiny Apps covers medium to advanced content about Shiny, so it will help people that are already familiar with building apps with Shiny, and who want to go one step further.

Arvustused

"ThinkRs book is a gradual and pleasant invitation to the production-ready shiny apps world. It focuses on the unfortunately too often forgotten general principles necessary to be successful in this quest, before exposing a comprehensive and robust workflow powered by the {golem} package. This books fills the not yet covered gap between shiny app development and deployment in such a thrilling way that it may be read in one sitting. Readers will appreciate the number of exclusive references like {shinypsum}, {gargoyle}, {crrry} and {dockerfiler} that will definitely help them to reach the production-ready graal. In the industry world, where processes robustness is a key toward productivity, this book will indubitably have a tremendous impact." David Granjon, Sr. Expert Data Science, Novartis

"[ This book] contains an excellent blend of both Shiny-specific topics and practical advice from software development that fits in nicely with Shiny apps. You will find many nuggets of wisdom sprinkled throughout these chapters." Eric Nantz, Host of the R-Podcast and the Shiny Developer Series (from the Foreword)

List of Figures xv
Introduction xix
Foreword xxix
Application presentation xxxi
I Building Successful {shiny} Apps 1(78)
1 About Successful {shiny} Apps
3(18)
1.1 A (very) short introduction to {shiny}
3(1)
1.2 What is a complex {shiny} application?
4(15)
1.2.1 Reaching the cliff of complexity
4(2)
1.2.2 Balancing complexities
6(1)
1.2.3 Assessing code complexity
7(11)
1.2.4 Production-grade software engineering
18(1)
1.3 What is a successful {shiny} app?
19(2)
1.3.1 It exists
19(1)
1.3.2 It is accurate
19(1)
1.3.3 It is usable
20(1)
1.3.4 It is immortal
20(1)
2 Planning Ahead
21(6)
2.1 Working with a "long-term" mindset
21(2)
2.1.1 Prepare for success
21(1)
2.1.2 Develop with the KISS principle
22(1)
2.2 Working as a team: Tools and structure
23(4)
2.2.1 From the tools point of view
23(2)
2.2.2 From the team point of view
25(2)
3 Structuring Your Project
27(28)
3.1 {shiny} app as a package
27(4)
3.1.1 What is in a production-grade {shiny} app?
27(4)
3.1.2 Resources
31(1)
3.2 Using {shiny} modules
31(17)
3.2.1 Why {shiny} modules?
32(3)
3.2.2 When to use {shiny} modules
35(1)
3.2.3 A practical walkthrough
35(8)
3.2.4 Communication between modules
43(5)
3.3 Structuring your app
48(7)
3.3.1 Business logic and application logic
48(3)
3.3.2 Small is beautiful (bis repetita)
51(1)
3.3.3 Conventions matter
51(4)
4 Introduction to {golem}
55(18)
4.1 What is {golem}?
55(1)
4.2 Understanding {golem} app structure
56(17)
4.2.1 DESCRIPTION and NAMESPACE
57(1)
4.2.2 R/
58(6)
4.2.3 golem-config
64(5)
4.2.4 inst/app/www/
69(2)
4.2.5 dev/
71(1)
4.2.6 man/
71(2)
5 The Workflow
73(6)
5.1 Step 1: Design
73(2)
5.2 Step 2: Prototype
75(1)
5.3 Step 3: Build
76(1)
5.4 Step 4: Strengthen
76(1)
5.5 Step 5: Deploy
77(2)
II Step 1: Design 79(44)
6 UX Matters
81(32)
6.1 Simplicity is gold
81(13)
6.1.1 How we read the web: Scanning content
82(5)
6.1.2 Building a self-evident app (or at least self-explanatory)
87(7)
6.2 The danger of feature-creep
94(5)
6.2.1 What is feature-creep?
94(2)
6.2.2 Too much reactivity
96(1)
6.2.3 Too much interactivity
97(2)
6.3 Web accessibility
99(14)
6.3.1 About accessibility
99(1)
6.3.2 Making your app accessible
99(10)
6.3.3 Evaluating your app accessibility and further reading
109(4)
7 Don't Rush into Coding
113(10)
7.1 Designing before coding
113(4)
7.1.1 The urge to code
113(1)
7.1.2 Knowing where to search
114(1)
7.1.3 About concept map
115(2)
7.2 Ask questions
117(8)
7.2.1 About the end users
117(1)
7.2.2 Building personas
118(1)
7.2.3 Pre-existing code-base
119(2)
7.2.4 Deployment
121(2)
III Step 2: Prototype 123(24)
8 Setting up for Success with {golem}
125(8)
8.1 Create a {golem}
125(1)
8.2 Setting things up with dev/01_start.R
126(3)
8.2.1 Fill the DESCRIPTION and set options
127(1)
8.2.2 Set common files
127(1)
8.2.3 Use recommended elements
128(1)
8.2.4 Add utility functions
128(1)
8.2.5 Changing the favicon
128(1)
8.3 Setting infrastructure for prototyping
129(4)
8.3.1 Add modules in dev/02_dev.R
129(1)
8.3.2 Add CSS and JS files
130(3)
9 Building an "ipsum-app"
133(14)
9.1 Prototyping is crucial
133(4)
9.1.1 Prototype, then polish
133(3)
9.1.2 The "UI first" approach
136(1)
9.2 Prototyping {shiny}
137(6)
9.2.1 Fast UI prototyping with {shinipsum}
137(4)
9.2.2 Using {fakir} for fake data generation
141(2)
9.3 Building with RMarkdown
143(6)
9.3.1 Define the content of the application
143(1)
9.3.2 Using the Rmd files as a laboratory notebook
144(1)
9.3.3 Rmd, Vignettes, and documentation first
144(3)
IV Step 3: Build 147(14)
10 Building the App with {golem}
149(12)
10.1 Add dependencies
149(2)
10.1.1 Package dependencies
149(1)
10.1.2 Importing packages and functions
150(1)
10.2 Submodules and utility functions
151(2)
10.3 Add tests
153(1)
10.4 Documentation and code coverage
154(4)
10.4.1 Vignette
154(1)
10.4.2 Code coverage and continuous integration
154(4)
10.5 Using {golem} dev functions
158(3)
V Step 4: Strengthen 161(44)
11 Build Yourself a Safety Net
163(32)
11.1 Testing your app
163(20)
11.1.1 Testing the business logic
163(2)
11.1.2 shiny::testServer()
165(1)
11.1.3 Testing the interactive logic
166(6)
11.1.4 Testing the app load
172(11)
11.2 A reproducible environment
183(12)
11.2.1 {renv}
184(6)
11.2.2 Docker
190(5)
12 Version Control
195(7)
12.1 Using version control with Git
195(4)
12.1.1 Why version control?
195(1)
12.1.2 Git basics: add - commit - push - pull
196(1)
12.1.3 About branches
197(1)
12.1.4 Issues
198(1)
12.2 Git integration
199(8)
12.2.1 With RStudio
199(1)
12.2.2 As part of a larger world
199(1)
12.2.3 About git-flow
199(3)
12.2.4 Further readings on Git
202(1)
12.3 Automated testing
202(3)
VI Step 5: Deploy 205(8)
13 Deploy Your Application
207(6)
13.1 Before deployment checklist
207(1)
13.2 Sharing your app as a package
208(2)
13.2.1 Install on your machine
208(1)
13.2.2 Share as a built package
209(1)
13.3 Deploying apps with {golem}
210(5)
13.3.1 RStudio environments
211(1)
13.3.2 Docker
212(1)
VII Optimizing 213(112)
14 The Need for Optimization
215(24)
14.1 Build first, then optimize
215(5)
14.1.1 Identifying bottlenecks
215(2)
14.1.2 Do you need faster functions?
217(1)
14.1.3 Don't sacrifice readability
218(2)
14.2 Tools for profiling
220(19)
14.2.1 Profiling R code
220(6)
14.2.2 Profiling {shiny}
226(11)
14.2.3 More resources about web-page performance
237(2)
15 Common Application Caveats
239(28)
15.1 Reactivity anti-patterns
239(16)
15.1.1 Reactivity is awesome...until it is not
239(3)
15.1.2 observe vs observeEvent
242(6)
15.1.3 Building triggers and watchers
248(3)
15.1.4 Using R6 as data storage
251(3)
15.1.5 Logging reactivity with {whereami}
254(1)
15.2 R does too much
255(8)
15.2.1 Rendering the UI from the server side
255(7)
15.2.2 Too much data in memory
262(1)
15.3 Reading data
263(4)
15.3.1 Including data in your application
263(1)
15.3.2 Reading external datasets
264(1)
15.3.3 Using external databases
265(1)
15.3.4 Data-source checklist
266(1)
16 Optimizing {shiny} Code
267(22)
16.1 Optimizing R code
267(1)
16.2 Caching elements
267(11)
16.2.1 What is caching?
267(2)
16.2.2 Native caching in R
269(4)
16.2.3 Caching in {shiny}
273(5)
16.3 Asynchronous in {shiny}
278(11)
16.3.1 How to
279(10)
17 Using JavaScript
289(24)
17.1 Introduction
289(3)
17.2 A quick introduction to JavaScript
292(6)
17.2.1 About JavaScript
292(1)
17.2.2 Including JavaScript code in your app
292(1)
17.2.3 Understanding HTML, class, and id
293(1)
17.2.4 Querying in Vanilla JavaScript
294(1)
17.2.5 About DOM events
295(1)
17.2.6 About j Query and j Query selectors
296(2)
17.3 Client-side JavaScript
298(5)
17.3.1 Common patterns
298(1)
17.3.2 Where to put them: Back to JavaScript Events
299(4)
17.4 JavaScript {shiny} communication
303(5)
17.4.1 From R to JavaScript
303(2)
17.4.2 From JavaScript to R
305(3)
17.5 About {shinyjs} JS functions
308(1)
17.6 One last thing: API calls
308(1)
17.7 Learn more about JavaScript
309(4)
17.7.1 {shiny} and JavaScript
310(1)
17.7.2 JavaScript basics
310(1)
17.7.3 jQuery
311(1)
17.7.4 Intermediate/advanced JavaScript
311(2)
18 A Gentle Introduction to CSS
313(12)
18.1 What is CSS?
313(4)
18.1.1 About CSS
313(2)
18.1.2 {shiny}'s default: fluidPage()
315(2)
18.2 Getting started with CSS
317(2)
18.2.1 About CSS syntax
318(1)
18.2.2 CSS selectors
318(1)
18.2.3 CSS properties
319(1)
18.3 Integrate CSS files in your {shiny} app
319(4)
18.3.1 Inline CSS
319(2)
18.3.2 Writing in a tags$style()
321(1)
18.3.3 Including external files
321(1)
18.3.4 Using R packages
322(1)
18.4 External resources
323(2)
VIII Appendix 325(32)
Appendix A Use Case: Building an App from Start to Finish
327(16)
Appendix B Session Info
343(14)
Index 357
Colin Fay has written the vast majority of this book. Hes responsible for its general structure, and for the original designer of the workflow described. Most of the time (if not every time) we actually refers to him. He is the lead developer of the {golem} framework, and creator of many tools described in this book. Colin works at ThinkR, a french agency focused on everything R-related. During the day, he helps companies to take full advantage of the power of R, by building tools (packages, web apps) and setting up infrastructure. His main areas of expertise are data & software engineering, infrastructure, web applications (front-end and back-end), and R in production. During the night, Colin is also an hyperactive open source developer and an open data advocate. You can find a lot of his work on his GitHub account (https://github.com/ColinFay) and on ThinkRs account (https://github.com/thinkr-open). He is also active in the R & Data community, and an international speaker.

Sébastien Rochette has been instrumental in the review of most of this book chapters. He has also written the section about prototyping in RMarkdown, a concept he initiated. Sébastien is a data scientist at ThinkR, where he teaches anything R related from beginner to expert level, guides R developers towards implementation of best practices, and creates tailor-made R solutions for the needs of his customers.

Vincent Guyader is the founder of ThinkR. He created the first proof-of-concept of a framework for {shiny} applications inside packages ; an idea which has led to the creation of {golem}. If you feel like a GitHub archaeologist, this very first version is still available with a little bit of exploration! With more than 10 years of experience with R, and a scientific and technical background, Vincent is an R-enthusiast. He still has his hands in the code, whether to develop applications, analyze data or build packages. When hes not coding, he plays with Docker and manages servers. He strongly believes that meeting highly technical challenges is not incompatible with pedagogy: he passionately trains very diverse learner profiles at R.

Cervan Girard has worked on some of the example applications that are used inside this book, namely {shinipsumdemo}, {databasedemo}, {graysacle}, {bs4dashdemo}, and {shinyfuture}. Cervan is Data Scientist at ThinkR. He is enthusiastic and motivated when it comes to rolling up his sleeves for new challenges, even if it means venturing dangerously into the depths of R, learning new languages and experimenting outside your comfort zone. Whatever the challenge, he remains reliable, constructive and efficient when it comes to using his skills to train or develop. He also enjoys training learners of all levels in the R language.