Adding headings and subheadings to existing code

When the code for a particular project starts to get long, I often wish that there was an easy way to insert differently formatted headings for the major and minor sections, with larger print and perhaps bolding or a different typeface, just to help me navigate my own code. So for instance, I am working on a project now that has about 40 pages of code in its main file. It is code that has evolved as I work, and it does not correspond to a pre-established outline very well. So it is already pretty rife with capitalization and comments and navigation is becoming a problem.

Is there a simple way to do this to a substantial existing body of code that does not demand that it be radically restructured? I have not previously used R Notebooks. Is this the easiest solution to this problem? Is there a good description somewhere of how to convert existing code to a Notebook, or otherwise insert differently forematted headers, as opposed to creating one from a blank slate?

I have catagorized this as RStudio general rather than specifically R Markdown because I am looking for the simplest approach to doing this one thing, which I think may be R Markdown but I am not sure of this.

I add a meta comment: the existing list of subhedings is pretty thin, and I think it would be beneficial to relax the requirements for creating new ones for a while. For instance, there is no subhead for formatting questions more generally, or for creation of headings, or for text except in a few specified contexts, etc.

Maybe using R in Jupyter Notebook?

Thanks! I've never used Jupiter Notebook either. I'll try that. Installimng it also installs Python, which is on my list of things to learn.

--Andrew

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.