Closed schmettow closed 5 years ago
@schmettow This does not seem to work for knitting a chapter by entering rmarkdown::render(<file name>)
into the RStudio console:
> rmarkdown::render('02_Variables.Rmd')
>
> processing file: 02_Variables.Rmd
> |. | 1%
> ordinary text without R code
>
> |. | 2%
> label: unnamed-chunk-2 (with options)
> List of 2
> $ eval : logi FALSE
> $ engine: chr "python"
>
> ...
> |..................... | 33%
> ordinary text without R code
>
> |...................... | 34%
> label: unnamed-chunk-16 (with options)
> List of 2
> $ error : logi TRUE
> $ engine: chr "python"
>
> Quitting from lines 254-255 (02_Variables.Rmd)
> Error: invalid syntax (<string>, line 1)
>
After some testing the chunk option error = TRUE
on my own and in reference to the respective documentation on chunk options, setting error = TRUE
means that the error message will be included in the knitted output.
warning, message, and error: Whether to show warnings, messages, and errors in the output document. Note that if you set error = FALSE, rmarkdown::render() will halt on error in a code chunk, and the error will be displayed in the R console.
This is not desirable for exercises on errorneous code snippets where the student needs to point out the error (e.g. exercise 2.7.4 in chapter 2).
For now, I will leave the engine blank in exercises where students need to find the error themselves. I will change the chunk option to {python error = True}
in wrong code snippets whose purpose is to demonstrate the error.
Throughout the book, chunks that produce error messages on purpose are made static by omitting the engine. It is preferred that these chunks are truly executed. The following chunk header prevents the knitting to come to a halt when errors are produced:
Use this for all chunks that produce errors on purpose.