When it comes to programming errors are a natural part of it. Sometimes you want to show such an error and then you want to show how to remove that error.

But if you have an error within your R-code chunk blogdown stops processing your article.

My first try was to catch the error with tryCatch()

1
2
3
4
5
6
tryCatch(
  {starwars %>% max_by(height_var, by = by_var)},
  error = function(err) {
    print(paste(err))
  }
)
1
## [1] "Error in starwars %>% max_by(height_var, by = by_var): could not find function \"%>%\"\n"

But that’s a little clumsy and there is a simpler way: Just use the option error = true for your code chunk:

1
starwars %>% max_by(height_var, by = by_var)
1
## Error in starwars %>% max_by(height_var, by = by_var): could not find function "%>%"