Quarto equivalent to RMarkdown setup chunk?

I am slowly converting to using Quarto instead of RMarkdown. One thing I still haven't figured out is if there is an equivalent to the RMarkdown setup chunk. E.g., I always used to start my RMarkdown documents with a chunk like

```{r setup}

This would allow me to avoid seeing all the messages and warnings from packages when I knit the document, and made sure it would be run before things below. Is there something similar for Quarto? I have tried context: setup and label: setup but neither of them seem to do it.

I'm now realizing that the piece that might have hidden the messages and warnings was the default include=FALSE that the setup chunk usually came with. Maybe I should add that to my Quarto docs! The other piece still holds-- does label: setup or context: setup offer any of the benefits of the RMarkdown setup chunk?

1 Like

This topic was automatically closed 21 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.

Sorry for the no answer on this. Asking on Quarto Discussion (Discussions · quarto-dev/quarto-cli · GitHub) will often get you a more quicker response by the dev team, as Community member may not be able to help with all question here on Quarto.

setup chunk has a special meaning in the RStudio IDE I believe, when interactively running chunks. It was introduced first for Shiny Documents. I believe this why it gets confusing.

Initially it is context for shiny, which should be supported in Quarto to

but Chunk label are used as a shortcut instead of setting context. See explanation in

Above we’ve shown the use of the context attribute to associate chunks with various execution contexts. The label of R chunks can also serve as a shorthand way of specifying a context (e.g. a chunk with label setup automatically gains the context="setup" attribute).

That is why both label: setup or context: setup should work. However, in Quarto the former is no shorthand of the latter, so using context should probably be preferred.

hope it helps