This question appears to be mentioned briefly here - Permanent Code Folding in RStudio - however for windows and a bit outdated. I am on OS X with RStudio version 0.99.891.
I use command-alt-L to fold code in R-studio, and would prefer if the code remains folded when I both (1) save/close/reopen the file, and (2) run the folded code. Currently, doing both (1) and (2) unfolds the code, which is slightly frustrating.
Anyone know if this is avoidable, or something I should learn to live with?
Thanks!
In addition, in Rstudio you can run the entire script by pressing Ctrl + Shift + Enter without selecting any code. In addition, there is a shortcut to source the current script file ( Ctrl + Shift + s ), which runs the script without echoing each line.
The easiest way to create a multi-line comment in RStudio is to highlight the text and press Ctrl + Shift + C. You can just as easily remove the comment by highlighting the text again and pressing Ctrl + Shift + C.
In latest R Studio (I work with v1. 0+), you can also click Ctrl + Shift + R , or go to menu Code > Insert Section . It will show a popup for your section name and add it. The title will then have a tiny arrow to hide the entire section until the next title.
If you put # ####
around every bit you want to fold and then when you open the script Alt+O (Cmd+Option+O on Mac) that will fold everything. Then highlighting the line and running it keeps it folded.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With