I am a beginner in using Markdown (I am using it with R studio and knitr).
I am struggling with a point that I hope you would be able to help me to figure it out.
I would like a chunk to be evaluated only if the output_format of the rmarkdown document is pdf. In other words, the chunk option "eval" automatically set to TRUE if the knitr output was selected as "knitr PDF". Otherwise, eval = FALSE.
In your view, what is the most straightforward way to do this.
Many thanks in advance
Try this:
```{r eval = knitr::is_latex_output()}
"Hi, I'm in a PDF!"
```
Or, to evaluate chunks only when you're not rendering to PDF:
```{r eval = !knitr::is_latex_output()}
"Hi, I'm not in a PDF!"
```
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With