knitr:编织具有解析错误的块 [英] knitr: knitting chunks with parsing errors
问题描述
是否可以编织带有解析错误的块?
Is it possible to knit chunks with parsing errors?
我想制作一个文档,说明在使用R进行编码时可以发现的一些不同类型的错误,但是,即使使用error = TRUE
,我似乎也无法编织带有分析错误的块.
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"
```
但是,该块不是:
```{r missing parenthesis, error = TRUE}
f <- function(x){
z <- sum(x
#
y <- x + 1
return(x + y + z)
}
```
它给出错误: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?
推荐答案
此自 evaluate 包> = v0.8.4(预计将来在CRAN上为v0.9).目前,您可以从Github安装评估 .
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.
这篇关于knitr:编织具有解析错误的块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!