More useful things...

Important functionality {.smaller}

```{R, eval=FALSE} while (...) { ... }

## Restarting R

Restart early, restart often... and don't restore data.

<center>![](images/RPiR6a-restart.png){ width=100% }</center>

## Errors

<center>![](images/RPiR6a-error.png){ width=100% }</center>

## Errors

<center>![](images/RPiR6a-error-read.png){ width=100% }</center>

## Debugging

There are lots of debugging options in R

<center>![](images/RPiR6a-debug.png){ width=100% }</center>

## `for (...)` loops - recap

Doing something a fixed number of times:
```{R, comment=""}
sequence <- seq(from = 0, to = 2, by = 0.5)

for (number in sequence) {
  print(number)
}

while (...) loops

Doing something until it is finished: {R, comment=""} number <- 0 max.number <- 2 increment <- 0.5 while (number <= max.number) { print(number) number <- number + increment }

Credits

Slide images: Jenny Bryan, https://github.com/jennybc/debugging

Death certificate (modified): Public Domain, https://commons.wikimedia.org/w/index.php?curid=214170

Autopsy painting by Rembrandt: https://www.mauritshuis.nl/en/explore/the-collection/artworks/the-anatomy-lesson-of-dr-nicolaes-tulp-146/detailgegevens/ Public Domain, https://commons.wikimedia.org/w/index.php?curid=64281722

The Night King: https://cnet4.cbsistatic.com/img/vugy5MvUVBvwcJf0JvKIBd1RwJE=/1200x675/2019/04/22/2b2fee8d-111a-4d19-ae83-4e61899cfd47/1nightking.jpg (probably copyright HBO)



IBAHCM/RPiR documentation built on Jan. 12, 2023, 7:41 p.m.