Rmd and code markup(down?)

rmarkdown

#1

The example document in the rmarkdown cheatsheet shows this:

```{r cars}
summary(cars)
```

but this seems to produce the same results:

```{r}
summary(cars)
```

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

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

TIA
Dan


#2

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.


#3

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


#4

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


#5

Ahh, thanks that helps.

Dan


#6

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


#7

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