Skip to content

Commit

Permalink
Working on week 4
Browse files Browse the repository at this point in the history
  • Loading branch information
robjhyndman committed Feb 21, 2024
1 parent b9d6917 commit 58d01c9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
Binary file added screenshots/Amanda_Gadrow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 2 additions & 5 deletions week4/examples.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Example 1

f <- function(a) g(a)
g <- function(b) h(b)
h <- function(c) i(c)
Expand All @@ -12,8 +14,3 @@ traceback()

options(error = recover)
f("a")

f <- function(n = 1e5) {
x <- rep(1, n)
rm(x)
}
4 changes: 4 additions & 0 deletions week4/index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ schedule |>
* renv
* caching

## Online resources

* [Amanda Gadrow - Debugging in R](https://posit.co/resources/videos/debugging-techniques-in-rstudio-2/)

```{r}
#| output: asis
show_slides(week)
Expand Down
17 changes: 8 additions & 9 deletions week4/slides.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ format:
fig-width: 7.5
fig-height: 3.5
include-in-header: ../header.tex
keep-tex: false
keep-tex: true
---

```{r}
Expand All @@ -35,6 +35,7 @@ source(here::here("course_info.R"))

* Google
* Stack Overflow
* Posit Community
* Create a minimal reproducible example
* Create a unit test
* Figure out where the test fails
Expand Down Expand Up @@ -95,7 +96,11 @@ traceback()
* Similar to `browser()` but no change to source code.
* Can be set in RStudio by clicking to the left of on the line number, or pressing `Shift + F9`.

* `options(error = recover)`
* `options(error = browser)`

## Example

[![Amanda Gadrow -- Debugging in R](../screenshots/Amanda_Gadrow.png)](https://posit.co/resources/videos/debugging-techniques-in-rstudio-2/)

## Interactive debugging

Expand Down Expand Up @@ -139,15 +144,9 @@ traceback()
* `sink()` : capture output to file.
* `options(warn = 2)` : turn warnings into errors.
* `rlang::with_abort()` : turn messages into errors.
* If R crashes, it is probably a bug in compiled code.
* If R or RStudio crashes, it is probably a bug in compiled code.
* Post minimal reproducible example to Posit Community or Stack Overflow.

## Exercise

Find the problem in the following code

????

# Profiling

## Profiling functions
Expand Down

0 comments on commit 58d01c9

Please sign in to comment.