Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Label code chunks in regular Rstudio .r script

Tags:

r

rstudio

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.
#----------------------------------------------------
like image 244
Tom Avatar asked Mar 19 '23 06:03

Tom


1 Answers

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

like image 172
David Arenburg Avatar answered Mar 31 '23 17:03

David Arenburg