Reputation: 5052
An .rmd
document in Rstudio is easy to navigate to the various code chunks using the little drop down in the bottom left corner of the script window.
In a regular .r
file, functions are listed with a helpful 'f' icon and the function name and commented chunks are also listed with a helpful '#' icon, but with (untitled) next to them.
What do I need to include in my comment so the "(untitled)" will be replaced with a label?
example:
#----------------------------------------------------
# FirstLabel - This is the first chunk of code I want to navigate to.
#----------------------------------------------------
Upvotes: 6
Views: 2872
Reputation: 346
Now there is a workaround, by using package ARTofR or bannerCommenter
For example:
ARTofR::xxx_title2('FirstLabel')
You will get
##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
## FirstLabel ----
##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
There are other styles in this package
Upvotes: 1
Reputation: 1595
####
still works, but now you can also add ----
at the end or click on Code>Insert Section...
# new section ----
The keyboard shortcut on windows is CTRL+SHIFT+R
and on Mac: CMD+SHIFT+R
Upvotes: 2
Reputation: 92282
Add ####
at the end of every comment you want to list
# FirstLabel - This is the first chunk of code I want to navigate to. ####
The nice thing about this is that you can hide everything between these comments using the drop down arrow on the left of the comment
Upvotes: 7