Is it possible to knit chunks with parsing errors?
I want to produce a document explaining some different types of errors one can find while coding in R, but it seems that I can't knit a chunk with parsing error, even with error = TRUE
.
For example, this chunk works fine and it shows the error messages:
```{r sum character, error = TRUE}
"1" + "2"
```
However, this chunk doesn't:
```{r missing parenthesis, error = TRUE}
f <- function(x){
z <- sum(x
#
y <- x + 1
return(x + y + z)
}
```
It gives the error: Error in parse(text = x, srcfile = src)
.
The idea here would be to show all error messages in the chunk "missing parenthesis", is this possible?
This has become possible since the evaluate package >= v0.8.4 (which is expected to be v0.9 on CRAN in the future). For now, you can install evaluate from Github.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With