Question

I have a very long R script files (one has 2723 lines), can I create a Table of Contents or Index to navigate through a file?

I would like to create a table of contents that points to a specific line on my text, say I have 20 variables to analyze, a table of contents would have 20 items.

Was it helpful?

Solution

You can insert sections using CTRL+SHIFT+R (Cmd+Shift+R on the Mac)

For more detail, see Code Folding and Sections

Code Folding RStudio supports both automatic and user-defined folding for regions of code. Code folding allows you to easily show and hide blocks of code to make it easier to navigate your source file and focus on the coding task at hand.

...

To navigate between code sections you can use the Jump To menu available at the bottom of the editor:

enter image description here

OTHER TIPS

Maybe u can click the button on the right top corner, Next to the source button. Unfortunately, I can't post the pic here.

Or if you want to export to PDF, HTML, or even a word file of your codes with its results, you can try Rmarkdown to make a TOC instead of a script.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top