Skip to content

Commit

Permalink
tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
shannonpileggi committed Jul 22, 2022
1 parent 8b2d737 commit ffef48b
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 59 deletions.
82 changes: 47 additions & 35 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,18 @@ <h1 class="title">Debugging</h1>
<p class="author">Shannon Pileggi</p>
</section>

<section id="agenda" class="title-slide slide level1 center">
<h1>Agenda</h1>
<p>Getting started</p>
<p>Troubleshooting</p>
<p>Moving on</p>
<p>Debugging your code</p>
<p>Debugging in RStudio</p>
<p>Debugging their code</p>
<p>Special cases</p>
<p>Read the source</p>
</section>

<section>
<section id="getting-started" class="title-slide slide level1 center">
<h1>Getting started</h1>
Expand Down Expand Up @@ -902,7 +914,7 @@ <h2>Your turn, exercise 01</h2>
</div>
<div class="cell">
<div class="cell-output-display">
<div class="countdown" id="timer_62d83d7f" style="right:0;bottom:0;font-size:2em;" data-audio="true" data-warnwhen="0">
<div class="countdown" id="timer_62da051a" style="right:0;bottom:0;font-size:2em;" data-audio="true" data-warnwhen="0">
<code class="countdown-time"><span class="countdown-digits minutes">15</span><span class="countdown-digits colon">:</span><span class="countdown-digits seconds">00</span></code>
</div>
</div>
Expand Down Expand Up @@ -1037,7 +1049,7 @@ <h2>Your turn, exercise 02</h2>
</div>
<div class="cell">
<div class="cell-output-display">
<div class="countdown" id="timer_62d83da6" style="right:0;bottom:0;" data-warnwhen="0">
<div class="countdown" id="timer_62da0273" style="right:0;bottom:0;" data-warnwhen="0">
<code class="countdown-time"><span class="countdown-digits minutes">07</span><span class="countdown-digits colon">:</span><span class="countdown-digits seconds">00</span></code>
</div>
</div>
Expand Down Expand Up @@ -1214,7 +1226,7 @@ <h2>Your turn, exercise 03</h2>
</div>
<div class="cell">
<div class="cell-output-display">
<div class="countdown" id="timer_62d83ae2" style="right:0;bottom:0;" data-warnwhen="0">
<div class="countdown" id="timer_62da054c" style="right:0;bottom:0;" data-warnwhen="0">
<code class="countdown-time"><span class="countdown-digits minutes">10</span><span class="countdown-digits colon">:</span><span class="countdown-digits seconds">00</span></code>
</div>
</div>
Expand All @@ -1232,23 +1244,22 @@ <h2>Pick your favorite</h2>
<h1>Special cases</h1>

</section>
<section id="warnings" class="slide level2">
<h2>Warnings</h2>
<section id="rmarkdown" class="slide level2 smaller">
<h2>Rmarkdown</h2>
<p><br></p>
<h4 id="troubleshooting-1">Troubleshooting:</h4>
<ol type="1">
<li><p>rmarkdown chunk option <code>error = TRUE</code> enables knitting with errors</p></li>
<li><p>insert <code>knitr::knit_exit()</code> and interactively work through .Rmd</p></li>
</ol>
<div class="fragment">
<p><br></p>
<p>If you want to dig deeper into a warning, you can convert them to errors to initiate debugging tools.</p>
<p><brshort></brshort></p>
<div class="cell">
<div class="sourceCode cell-code" id="cb27"><pre class="sourceCode numberSource r number-lines code-with-copy"><code class="sourceCode r"><span id="cb27-1"><a href="#cb27-1"></a>?options</span>
<span id="cb27-2"><a href="#cb27-2"></a><span class="fu">options</span>(<span class="at">warn =</span> <span class="dv">0</span>) <span class="co"># default, stores warnings until top-level function returns</span></span>
<span id="cb27-3"><a href="#cb27-3"></a><span class="fu">options</span>(<span class="at">warn =</span> <span class="dv">1</span>) <span class="co"># warnings are printed as they occur</span></span>
<span id="cb27-4"><a href="#cb27-4"></a><span class="fu">options</span>(<span class="at">warn =</span> <span class="dv">2</span>) <span class="co"># upgrades warnings to errors</span></span>
<span id="cb27-5"><a href="#cb27-5"></a></span>
<span id="cb27-6"><a href="#cb27-6"></a></span>
<span id="cb27-7"><a href="#cb27-7"></a><span class="co"># initiate recover on warning</span></span>
<span id="cb27-8"><a href="#cb27-8"></a><span class="fu">options</span>(<span class="at">warn =</span> <span class="dv">2</span>, <span class="at">error =</span> recover)</span>
<span id="cb27-9"><a href="#cb27-9"></a><span class="co"># restore original settings</span></span>
<span id="cb27-10"><a href="#cb27-10"></a><span class="fu">options</span>(<span class="at">warn =</span> <span class="dv">0</span>, <span class="at">error =</span> <span class="cn">NULL</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<h4 id="debugging">Debugging:</h4>
<ol type="1">
<li><p>Adv R Ch 22.5.3 RMarkdown <a href="https://adv-r.hadley.nz/debugging.html#rmarkdown" class="uri">https://adv-r.hadley.nz/debugging.html#rmarkdown</a></p></li>
<li><p>WTF Ch 11.4 Debugging in Rmarkdown documents <a href="https://rstats.wtf/debugging-r-code.html#debugging-in-r-markdown-documents" class="uri">https://rstats.wtf/debugging-r-code.html#debugging-in-r-markdown-documents</a></p></li>
</ol>
</section>
<section id="piped-expressions" class="slide level2">
<h2>Piped expressions</h2>
Expand All @@ -1257,7 +1268,7 @@ <h2>Piped expressions</h2>
<div class="fragment">
<p><br></p>
<div class="cell">
<div class="sourceCode cell-code" id="cb28"><pre class="sourceCode numberSource r number-lines code-with-copy"><code class="sourceCode r"><span id="cb28-1"><a href="#cb28-1"></a><span class="fu">options</span>(<span class="at">error =</span> rlang<span class="sc">::</span>entrace, <span class="at">rlang_backtrace_on_error =</span> <span class="st">"branch"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="sourceCode cell-code" id="cb27"><pre class="sourceCode numberSource r number-lines code-with-copy"><code class="sourceCode r"><span id="cb27-1"><a href="#cb27-1"></a><span class="fu">options</span>(<span class="at">error =</span> rlang<span class="sc">::</span>entrace, <span class="at">rlang_backtrace_on_error =</span> <span class="st">"branch"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p>gives trimmed tracebacks when using pipes</p>
</div>
Expand All @@ -1269,22 +1280,23 @@ <h2>Piped expressions</h2>
</ul>
</div>
</section>
<section id="rmarkdown" class="slide level2 smaller">
<h2>Rmarkdown</h2>
<p><br></p>
<h4 id="troubleshooting-1">Troubleshooting:</h4>
<ol type="1">
<li><p>rmarkdown chunk option <code>error = TRUE</code> enables knitting with errors</p></li>
<li><p>insert <code>knitr::knit_exit()</code> and interactively work through .Rmd</p></li>
</ol>
<div class="fragment">
<section id="warnings" class="slide level2">
<h2>Warnings</h2>
<p><br></p>
<p>If you want to dig deeper into a warning, you can convert them to errors to initiate debugging tools.</p>
<p><brshort></brshort></p>
<div class="cell">
<div class="sourceCode cell-code" id="cb28"><pre class="sourceCode numberSource r number-lines code-with-copy"><code class="sourceCode r"><span id="cb28-1"><a href="#cb28-1"></a>?options</span>
<span id="cb28-2"><a href="#cb28-2"></a><span class="fu">options</span>(<span class="at">warn =</span> <span class="dv">0</span>) <span class="co"># default, stores warnings until top-level function returns</span></span>
<span id="cb28-3"><a href="#cb28-3"></a><span class="fu">options</span>(<span class="at">warn =</span> <span class="dv">1</span>) <span class="co"># warnings are printed as they occur</span></span>
<span id="cb28-4"><a href="#cb28-4"></a><span class="fu">options</span>(<span class="at">warn =</span> <span class="dv">2</span>) <span class="co"># upgrades warnings to errors</span></span>
<span id="cb28-5"><a href="#cb28-5"></a></span>
<span id="cb28-6"><a href="#cb28-6"></a></span>
<span id="cb28-7"><a href="#cb28-7"></a><span class="co"># initiate recover on warning</span></span>
<span id="cb28-8"><a href="#cb28-8"></a><span class="fu">options</span>(<span class="at">warn =</span> <span class="dv">2</span>, <span class="at">error =</span> recover)</span>
<span id="cb28-9"><a href="#cb28-9"></a><span class="co"># restore original settings</span></span>
<span id="cb28-10"><a href="#cb28-10"></a><span class="fu">options</span>(<span class="at">warn =</span> <span class="dv">0</span>, <span class="at">error =</span> <span class="cn">NULL</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<h4 id="debugging">Debugging:</h4>
<ol type="1">
<li><p>Adv R Ch 22.5.3 RMarkdown <a href="https://adv-r.hadley.nz/debugging.html#rmarkdown" class="uri">https://adv-r.hadley.nz/debugging.html#rmarkdown</a></p></li>
<li><p>WTF Ch 11.4 Debugging in Rmarkdown documents <a href="https://rstats.wtf/debugging-r-code.html#debugging-in-r-markdown-documents" class="uri">https://rstats.wtf/debugging-r-code.html#debugging-in-r-markdown-documents</a></p></li>
</ol>
</section>
<section id="debugging-special-cases" class="slide level2">
<h2>Debugging special cases</h2>
Expand Down Expand Up @@ -1361,7 +1373,7 @@ <h2>Your turn, investigating a CRAN package</h2>
</div>
<div class="cell">
<div class="cell-output-display">
<div class="countdown" id="timer_62d83c98" style="right:0;bottom:0;" data-warnwhen="0">
<div class="countdown" id="timer_62da0289" style="right:0;bottom:0;" data-warnwhen="0">
<code class="countdown-time"><span class="countdown-digits minutes">03</span><span class="countdown-digits colon">:</span><span class="countdown-digits seconds">00</span></code>
</div>
</div>
Expand Down Expand Up @@ -1405,7 +1417,7 @@ <h2>Your turn, investigating source code</h2>
<p><em>Hints on next slides.</em></p>
<div class="cell">
<div class="cell-output-display">
<div class="countdown" id="timer_62d83b9a" style="right:0;bottom:0;" data-warnwhen="0">
<div class="countdown" id="timer_62da0291" style="right:0;bottom:0;" data-warnwhen="0">
<code class="countdown-time"><span class="countdown-digits minutes">05</span><span class="countdown-digits colon">:</span><span class="countdown-digits seconds">00</span></code>
</div>
</div>
Expand Down
74 changes: 51 additions & 23 deletions index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,27 @@ execute:
freeze: auto
---

# Agenda


Getting started

Troubleshooting

Moving on

Debugging your code

Debugging in RStudio

Debugging their code

Special cases

Read the source



# Getting started

```{r}
Expand Down Expand Up @@ -85,6 +106,8 @@ Artwork by [\@allison_horst](https://twitter.com/allison_horst).
<https://github.com/allisonhorst/stats-illustrations>
:::



# Troubleshooting

## 1. Search
Expand Down Expand Up @@ -219,6 +242,7 @@ Troubleshooting strategies:
<https://giphy.com/gifs/TreehouseDirect-agent-binky-8UabbehIqkR0akDt1y>
:::


# Moving on

<br>
Expand Down Expand Up @@ -904,27 +928,27 @@ countdown(

# Special cases

## Warnings
## Rmarkdown {.smaller}

<br>

If you want to dig deeper into a warning, you can convert them to errors to initiate debugging tools.
#### Troubleshooting:

<brshort>
1. rmarkdown chunk option `error = TRUE` enables knitting with errors

```{r, eval=FALSE, echo=TRUE}
?options
options(warn = 0) # default, stores warnings until top-level function returns
options(warn = 1) # warnings are printed as they occur
options(warn = 2) # upgrades warnings to errors
2. insert `knitr::knit_exit()` and interactively work through .Rmd

. . .

<br>

#### Debugging:

1. Adv R Ch 22.5.3 RMarkdown <https://adv-r.hadley.nz/debugging.html#rmarkdown>

2. WTF Ch 11.4 Debugging in Rmarkdown documents <https://rstats.wtf/debugging-r-code.html#debugging-in-r-markdown-documents>

# initiate recover on warning
options(warn = 2, error = recover)
# restore original settings
options(warn = 0, error = NULL)

```

## Piped expressions

Expand All @@ -950,25 +974,29 @@ gives trimmed tracebacks when using pipes

- Matt Dray 2019 blog post [Fix leaky pipes in R](https://www.rostrum.blog/2019/04/07/fix-leaky-pipes/)

## Rmarkdown {.smaller}

<br>

#### Troubleshooting:
## Warnings

1. rmarkdown chunk option `error = TRUE` enables knitting with errors
<br>

2. insert `knitr::knit_exit()` and interactively work through .Rmd
If you want to dig deeper into a warning, you can convert them to errors to initiate debugging tools.

. . .
<brshort>

<br>
```{r, eval=FALSE, echo=TRUE}
?options
options(warn = 0) # default, stores warnings until top-level function returns
options(warn = 1) # warnings are printed as they occur
options(warn = 2) # upgrades warnings to errors
#### Debugging:
1. Adv R Ch 22.5.3 RMarkdown <https://adv-r.hadley.nz/debugging.html#rmarkdown>
# initiate recover on warning
options(warn = 2, error = recover)
# restore original settings
options(warn = 0, error = NULL)
2. WTF Ch 11.4 Debugging in Rmarkdown documents <https://rstats.wtf/debugging-r-code.html#debugging-in-r-markdown-documents>
```

## Debugging special cases

Expand Down
Loading

0 comments on commit ffef48b

Please sign in to comment.