Show RMD code chunk options in rendered file

I would like to show ALL of the code I use to generate a figure in my rendered document using RMarkdown. For example, what I would like to see in my rendered document (either pdf or html) is this:

"```{r coolplot, fig.cap="Cool plot",echo=T}

"knitr::include_graphics("cool_plot.pdf")

"```

But when I run this code, all I see is the following code chunk:

knitr::include_graphics("cool_plot.pdf")

Is there an easy way to accomplish this?

Aren't those identical? Or am I not seeing something?

You're right, thanks for pointing out. I've edited. Apparently same problem is happening here. I'm trying to find a way to include the "```{r ... }" chunk options in the output of my RMD document. I want folks to be able to see exactly how I'm getting the output.

Got it! You want to show code verbatim - here's instructions on how to accomplish that: 5.6 Verbatim code chunks | R Markdown Cookbook.

1 Like

Thank you! This was exactly what I needed. It's working great.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.