Rmd and code markup(down?)

The example document in the rmarkdown cheatsheet shows this:

```{r cars}

but this seems to produce the same results:


What is the purpose of putting "cars" into {r cars}?

I can't find anything in the cheatsheet that explains its purpose.


The purpose is that you can name chunks with a unique name.
These names make it easier for you to organize your code, for example you can use them like a comment, which is saying whtat the actual chunk is doing. Note that you can also see the chunkname in the commandline, when the script gets executed. In this way, you can actually see where the script is hanging, when it takes a litlle bit longer.

1 Like

Hi Dan,

Adding cars to ```{r cars} will label that chunk with the title "cars".

Maelle Salmon has written a good post on the benefits of naming your chunks


It would be kinda nice if the chunk names showed up in the Document outline
Also giving same label to 2 chunks means the rmd won't run

Ahh, thanks that helps.


They will: (Global) Options > R Markdown > Show in Document Outline: Selection and [All/Named] Chunks.

1 Like

Cheers. And differentiated from the section :smiley:
There is so much in RStudio. Is there a webinar covering recent version?