Commenting rmarkdown / knitr to prevent R score

The recommendation for comments in .Rmddocuments for using HTML comments is <!-- comment here -->not enough. I would like to comment on a section of my document that includes inline ratings:

I haven't defined `x` yet.

<!-- So when I say that `x` is `r x` in the text, I'd like to comment it out -->

Knitting this fails:

#   |.................................................................| 100%
#    inline R code fragments
# 
# 
# 
# 
# processing file: test.Rmd
# Quitting from lines 2-3 (test.Rmd)
# Error in eval(expr, envir, enclos) : object 'x' not found
# Calls: <Anonymous> ... in_dir -> inline_exec -> withVisible -> eval -> eval
# Execution halted

One option is to comment on each built-in section:

I haven't defined `x` yet.

So when I say that `x` is `r #x` in the text, I'd like to comment it out

But this suffers if I would like to comment on a whole paragraph with several such inline calculations, for example. Is there a more canonical way to do this?

+4
source share
2 answers

@NicE, knitr , , R R , . , rmarkdown:

Define if bold `r bold <- TRUE`  
This text is `r ifelse(bold, "**bold**", "_italic_")`.

:

, .

, , - eval=FALSE echo=FALSE

```{r, eval=FALSE, echo=FALSE}
So when I say that `x` is `r x` in the text, I'd like to comment it out
```
+5

, yaml ,

---
title: "Untitled"
author: "baptiste"
date: "10/21/2017"
output: html_document
---

I haven't defined `x` yet.

---
# here a comment
# ```{r}
# x = pi
# ```
---

, r, .

0

Source: https://habr.com/ru/post/1676373/


All Articles