简体   繁体   English

旋转 R 脚本时忽略块选项 eval=FALSE

[英]Chunk option eval=FALSE ignored when spinning R-script

Spinning the following code (by clicking compile report in Rstudio):旋转以下代码(通过单击 Rstudio 中的编译报告):

#+ eval = FALSE
This line should not be syntax-checked, but it is.

Returns this error:返回此错误:

Error in parse(text = x, keep.source = TRUE) : 
  <text>:2:6: unexpected symbol
1: #+ eval = FALSE
2: This line

Knitting the equivalent Rmd-chunk works fine:编织等效的 Rmd-chunk 效果很好:

```{r, eval = FALSE}
Using Rmd, eval=FALSE disables the syntax-check, and does not error

I was expecting that I could spin a chunk syntactically incorrect code without getting an error ( https://bookdown.org/yihui/rmarkdown-cookbook/spin.html ).我期待我可以旋转一大块语法不正确的代码而不会出错( https://bookdown.org/yihui/rmarkdown-cookbook/spin.html )。 Am I mistaken for expecting this?我是不是误以为会这样?

Thanks.谢谢。

This is not possible, but a workaround is to quote the sentence :这是不可能的,但一种解决方法是引用以下句子:

# Syntax checked:
2+2 
#> [1] 4

# Not syntax checked:
"
2 a 
"
#> [1] "\n2 a \n"

(source: Yihui Xie's comment above at 28jun2022) (来源:28jun2022 谢一辉以上评论)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM