Reputation: 1513
In an R Markdown (.Rmd
) file, how do you comment out unused text? I'm not referring to the text in the R code chunk, but the general texts, like % in LaTex for example.
Upvotes: 144
Views: 105691
Reputation: 1
We can use
# Converted R Markdown code chunk in .Rmd file
`r ''````{r stream, eval=FALSE}
strm <- FastqStreamer("a.fastq.gz")
repeat {
fq <- yield(strm)
if (length(fq) == 0)
break
## process chunk
}
This is found from a https://github.com/rstudio/rmarkdown-book/blob/main/03-documents.Rmd bookdown which is used we want a code block to not execute while knitting.
Does it solves your problem??? if you have any questions please let me know.
Upvotes: 0
Reputation: 1
You can always turn off code by putting it within an if(F){} statement.
Upvotes: 0
Reputation: 545
After drag the lines you want to make comment, press SHIFT+CMD+C (macOS), SHIFT+CTRL+C (Windows). This is the shortcut of R Markdown editor (R Studio) to comment out.
Upvotes: 26
Reputation: 77096
Extra yaml blocks can be used anywhere inside the document, and commented out with #
---
title: "Untitled"
output: html_document
---
No comment.
---
# here's a comment
# ```{r}
# x = pi
# ```
---
Note however that this does not prevent knitr from evaluating inline r code.
Upvotes: 40
Reputation: 13372
I think you should be able to use regular html comments:
<!-- regular html comment -->
Does this work for you?
Upvotes: 206