Include code that does not run in Rpresentation Markdown

RMarkdownPresentation

R Problem Overview


I have a .Rpres file in RStudio. I would like to include code, but not have it run (I am only showing the code to explain how it works). Is it possible to accomplish this (and ensure that it will not produce errors, because it is not running)?

R Solutions


Solution 1 - R

Have you tried eval=FALSE in the knitr code chunk options? e.g.:

```{r eval=FALSE}
print("Don't run me")
```

Solution 2 - R

{r, eval=F, echo=T} will include the R source code in the output file while it is not evaluated

Solution 3 - R

Posting for anyone who may come across this like I have. I've found that for small examples (if you don't want to use chunks), you can also just use back ticks like you would with regular markdown inline, but just don't add the "r" at the beginning:

`plot(cars)`

Will print the code itself, but will not print the plot.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser2808302View Question on Stackoverflow
Solution 1 - RhrbrmstrView Answer on Stackoverflow
Solution 2 - RJdPView Answer on Stackoverflow
Solution 3 - RMeghan H.View Answer on Stackoverflow