Using Rstudio to edit an Rmarkdown file, I use HTML comments mark out large blocks that I don't want to have processed or in the output. This works just fine in Rstudio, which ignores everything in the comments. However, when I ask Rstudio to knit the document, knitr is executing the R code blocks in the comments.
Here's an MWE .Rmd file:
# Important stuff I want to see
This is what I want to see:
```{r}
pi # I like pi
```
<!---
**This section commented out, as not ready to be knit yet**
This is what I do not want to see:
```{r}
cake # I also like cake, but it's undefined
```
-->
This causes knitr to fail with Error in eval(expr, envir, enclos) : object 'cake' not found ... Execution halted
Is there an easy way to comment out whole swathes of an Rmarkdown file which prevents knitr from executing the R code chunks in the comments?
I have looked at global comment option for R markdown in knitr and Comments in Markdown, as well as https://yihui.name/knitr/, but didn't find a solution.