R Markdown (Rmd) hides a paragraph of a general text based on a condition

I am working on a Rmd report and depending on the variable R I want to decide whether to include a paragraph or not.

eg.

##Abstract
paragraph Blurb

If result type is 1 then
another paragraph of blurb

I cannot find an easy way to do this. I tried using a piece of code.

eg

```{r echo=FALSE}
    if ( resultType1 ) {
        cat(c("lines of blurb","more lines of blurb"))
    }
```

Unfortunately, this displays an optional paragraph in the plus box in a completely different font from the general paragraph paragraph and has the feeling that there is a better way to do this

+4
source share
1 answer

how about using results='asis'a block of code in the header.

```{r, echo=FALSE, results='asis'}
if ( resultType1 ) {
  cat(c("lines of blurb","more lines of blurb"))
}
```

You can also print C ## headers, etc.

+6
source

All Articles