|
1 | 1 | ---
|
2 |
| -title: "Untitled" |
3 |
| -author: "Jonathan McPherson"" |
| 2 | +author: "Jonathan McPherson" |
4 | 3 | title: Debugging with Shiny
|
5 |
| -output: ioslides_presentation |
| 4 | +output: |
| 5 | + ioslides_presentation: |
| 6 | + css: shiny-slides.css |
| 7 | + highlight: textmate |
| 8 | + self_contained: no |
6 | 9 | ---
|
7 | 10 |
|
8 | 11 | # Overview
|
9 | 12 |
|
10 |
| -We'll cover four main areas: |
11 |
| -- Tracing Execution |
12 |
| -- Tracing Errors |
| 13 | +## Outline |
| 14 | + |
| 15 | +We'll cover three main areas: |
| 16 | + |
13 | 17 | - Debugging
|
| 18 | +- Tracing |
| 19 | +- Errors |
| 20 | + |
| 21 | +# Debugging |
| 22 | + |
| 23 | +"Finding your bug is a process of confirming the many things that you believe are true — until you find one which is not true." |
| 24 | + |
| 25 | +-- Norm Matloff |
| 26 | + |
| 27 | +Author of *The Art of R Programming* and *The Art of Debugging* |
| 28 | + |
| 29 | +## Breakpoints |
| 30 | + |
| 31 | + |
| 32 | + |
| 33 | +*Breakpoint (armed)* |
| 34 | + |
| 35 | +## Breakpoints |
| 36 | + |
| 37 | + |
| 38 | + |
| 39 | +*Stepping after execution* |
| 40 | + |
| 41 | +## Breakpoints {.build} |
| 42 | + |
| 43 | +### Pros |
14 | 44 |
|
15 |
| -# Showcase mode |
| 45 | +- Doesn't change code |
| 46 | +- Can inspect local values/stack |
| 47 | +- Can step through following code |
16 | 48 |
|
17 |
| -# The Reactive Graph |
| 49 | +### Cons |
18 | 50 |
|
19 |
| -# JavaScript error console |
| 51 | +- Only works inside `shinyServer` |
| 52 | +- Can't tell you why something isn't happening |
| 53 | +- Interrupts program flow; not conditional |
20 | 54 |
|
21 |
| -# Shiny traces |
| 55 | +## browser() |
22 | 56 |
|
23 |
| -# Deployed Apps |
| 57 | + |
24 | 58 |
|
25 |
| -options() |
| 59 | +## browser() {.build} |
26 | 60 |
|
27 |
| -```{r} |
28 |
| -# Check JavaScript error console (btw it would be great to have a decent experience for doing this in RStudio someday) |
29 |
| -# options(shiny.trace = TRUE) to see what messages are going back and forth between the browser and server. This is mostly useful when you're writing your own custom bindings, or if you're not sure why something's not updating. |
30 |
| -# options(shiny.error) and options(shiny.observer.error). Honestly I'm not sure if these are working correctly. That was something I was hoping one of us (you, Winston, or I) could look into. |
31 |
| -# Collecting tracebacks when errors occur in observers/reactives. Again, not exactly sure what the answer is here, also needs investigation by one of us. |
| 61 | +### Pros |
| 62 | + |
| 63 | +- Similar advantages to breakpoints |
| 64 | +- Valid anywhere an R expression is valid |
| 65 | +- Can be made conditional |
| 66 | + |
| 67 | +### Cons |
| 68 | + |
| 69 | +- Changes your code! |
| 70 | +- Interrupts program flow |
| 71 | +- Can't tell you why something isn't happening |
| 72 | + |
| 73 | +# Tracing |
| 74 | + |
| 75 | +## Showcase Mode |
| 76 | + |
| 77 | + |
| 78 | + |
| 79 | +```{r eval=FALSE} |
| 80 | +runApp(..., display.mode="showcase") |
| 81 | +``` |
| 82 | + |
| 83 | +## Reactive Log |
| 84 | + |
| 85 | + |
| 86 | + |
| 87 | +```{r eval=FALSE} |
| 88 | +options(shiny.reactlog=TRUE) |
| 89 | +runApp(...) |
| 90 | +showReactLog() |
32 | 91 | ```
|
| 92 | + |
| 93 | +# Error Handling |
| 94 | + |
| 95 | + |
| 96 | + |
0 commit comments