Close and open all chunks feature in a RMarkdown script in Rstudio
Asked Answered
M

1

16

My Rmarkdown scripts are getting quite large lately. Especially the code inside the R-chunk which makes over-viewing the whole script more and more tricky. Luckily in RStudio there's the functionality to close resp. minimize the code chunk to one line! However when chunks are becoming more, it takes time to close them all by hand.

Question: Is there a feature to close them all at once? Say when starting to work on the script and then reopen single chunks when needed.

PS: Wasn't sure to post this as a feature request on github or here.

Miguel answered 22/8, 2017 at 10:58 Comment(2)
I put my long chunks in a separate file and use knitr::read_chunk to find them. You then just give the chunk name. This also makes the chunks usable by several different documents/presentationsCosmic
ah, will try that approach!Miguel
E
22

Edit > Folding > Collapse All

Alternatively, (on Windows) Alt+O.

Electrodialysis answered 22/8, 2017 at 11:23 Comment(3)
thanks wasn't aware of that feature! However, I was wandering if such a feature exists for the code chunks only (This works on chapters).Miguel
I didn't realise that it collapsed chapters, too. That's the only one I know of, unfortunately.Electrodialysis
As an aside, Alt + Shift + O reverses it, or Expands AllSooth

© 2022 - 2024 — McMap. All rights reserved.