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) |
|
|
19 | (1) |
|
|
19 | (1) |
|
|
20 | (1) |
|
|
20 | (1) |
|
|
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) |
|
|
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) |
|
|
48 | (7) |
|
3.3.1 Business logic and application logic |
|
|
48 | (3) |
|
3.3.2 Small is beautiful (bis repetita) |
|
|
51 | (1) |
|
|
51 | (4) |
|
4 Introduction to {golem} |
|
|
55 | (18) |
|
|
55 | (1) |
|
4.2 Understanding {golem} app structure |
|
|
56 | (17) |
|
4.2.1 DESCRIPTION and NAMESPACE |
|
|
57 | (1) |
|
|
58 | (6) |
|
|
64 | (5) |
|
|
69 | (2) |
|
|
71 | (1) |
|
|
71 | (2) |
|
|
73 | (6) |
|
|
73 | (2) |
|
|
75 | (1) |
|
|
76 | (1) |
|
|
76 | (1) |
|
|
77 | (2) |
II Step 1: Design |
|
79 | (44) |
|
|
81 | (32) |
|
|
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) |
|
|
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) |
|
|
113 | (10) |
|
7.1 Designing before coding |
|
|
113 | (4) |
|
|
113 | (1) |
|
7.1.2 Knowing where to search |
|
|
114 | (1) |
|
|
115 | (2) |
|
|
117 | (8) |
|
7.2.1 About the end users |
|
|
117 | (1) |
|
|
118 | (1) |
|
7.2.3 Pre-existing code-base |
|
|
119 | (2) |
|
|
121 | (2) |
III Step 2: Prototype |
|
123 | (24) |
|
8 Setting up for Success with {golem} |
|
|
125 | (8) |
|
|
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) |
|
|
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) |
|
|
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) |
|
|
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) |
|
|
153 | (1) |
|
10.4 Documentation and code coverage |
|
|
154 | (4) |
|
|
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) |
|
|
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) |
|
|
184 | (6) |
|
|
190 | (5) |
|
|
195 | (10) |
|
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) |
|
|
197 | (1) |
|
|
198 | (1) |
|
|
199 | (3) |
|
|
199 | (1) |
|
12.2.2 As part of a larger world |
|
|
199 | (1) |
|
|
199 | (3) |
|
12.2.4 Further readings on Git |
|
|
202 | (1) |
|
|
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) |
|
|
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) |
|
|
220 | (19) |
|
|
220 | (6) |
|
|
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) |
|
|
255 | (8) |
|
15.2.1 Rendering the UI from the server side |
|
|
255 | (7) |
|
15.2.2 Too much data in memory |
|
|
262 | (1) |
|
|
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) |
|
|
267 | (1) |
|
|
267 | (11) |
|
|
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) |
|
|
279 | (10) |
|
|
289 | (24) |
|
|
289 | (3) |
|
17.2 A quick introduction to JavaScript |
|
|
292 | (6) |
|
|
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) |
|
|
295 | (1) |
|
17.2.6 About j query and j Query selectors |
|
|
296 | (2) |
|
17.3 Client-side JavaScript |
|
|
298 | (5) |
|
|
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 {shiny]s} 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) |
|
|
310 | (1) |
|
|
311 | (1) |
|
17.7.4 Intermediate/advanced JavaScript |
|
|
311 | (2) |
|
18 A Gentle Introduction to CSS |
|
|
313 | (12) |
|
|
313 | (4) |
|
|
313 | (2) |
|
18.1.2 {shiny}'s default: fluidPage |
|
|
315 | (2) |
|
18.2 Getting started with CSS |
|
|
317 | (2) |
|
|
318 | (1) |
|
|
318 | (1) |
|
|
319 | (1) |
|
18.3 Integrate CSS files in your {shiny} app |
|
|
319 | (4) |
|
|
319 | (2) |
|
18.3.2 Writing in a tags$style() |
|
|
321 | (1) |
|
18.3.3 Including external file, |
|
|
321 | (1) |
|
|
322 | (1) |
|
|
323 | (2) |
VIII Appendix |
|
325 | (32) |
|
Appendix A Use Case: Building an App from Start to Finish |
|
|
327 | (16) |
|
|
343 | (14) |
Index |
|
357 | |