简体   繁体   中英

Chunk option eval=FALSE ignored when spinning R-script

Spinning the following code (by clicking compile report in 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:

```{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 ). 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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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