Knitr: knitting pieces with parsing errors

Can I knit pieces with parsing errors?

I want to create a document explaining some of the different types of errors that can be found when coding in R, but it seems that I cannot knit a piece with a parsing error even with error = TRUE.

For example, this snippet works fine, and it shows error messages:

```{r sum character, error = TRUE}
"1" + "2"
```

However, this snippet does not execute:

```{r missing parenthesis, error = TRUE}
f <- function(x){
  z <- sum(x
  #
  y <- x + 1
  return(x + y + z)
}
```

It produces an error: Error in parse(text = x, srcfile = src).

The idea here would be to show all the error messages in the “Missing Brackets” piece, is this possible?

+4
source share
1 answer

, package >= v0.8.4 (, , v0.9 CRAN ). Github.

+7

All Articles