Search code examples
rrstudior-markdownrnotebook

R Run chunk while folded/hidden in Rmarkdown RNotebook


I'm struggling to find anything like this on forums or manuals, but I would like to find this feature.

Is there a way to run a chunk in Rstudio while keeping it hidden like below?

The chunk is hidden here

This feature would be great when writing documentation/write-up within the same file and testing and updating the code.

As far as I can see, whichever way I run it, it unfolds/shows the chunk contents like below.

The chunk is no longer hidden

Thanks!


Solution

  • I found that when setting chunk output in console in settings, then running the chunks via ctrl+alt+R or ctrl+shift+enter or mouse click on the run button keeps them folded while running.

    Only setting chunk output inline unfolds the chunks obligatorily it seems.