insert_l_break | R Documentation |
A function designed to use as an RStudio
add-in for structuring code.
There are three levels of granularity:
level 1 sections, which are high-level blocks denoted by
### ______________________
level 2 sections, which are medium-level blocks denoted by
## ..............................................
level 3 sections, which are low-level blocks denoted by
# . . . . . . . . . . . . . . . . . . . . . . . ..
For optimal use, we recommend specifying keyboard shortcuts in the add-in settings. A title can be added to the section as well. When calling the function, a shiny app is opened in the viewer pane, where the title can be specified. If the field remains empty, only a section break is created without title. You may hit enter instead of clicking on "done" to confirm your choice.
insert_l1_break()
insert_l2_break()
insert_l3_break()
The breaks characters (___
, ...
, . .
) were
chosen such that they reflect the level of granularity, namely ___
has a much higher visual density than . .
We recommend starting off by grouping code into level 2 blocks.
The advantage is that in both directions of granularity, there is another
layer (___
and ...
) left. When the code base grows, there
might be a need to extend in both directions.
In order to be recognised as sections by RStudio,
all titles end with four hashes (see example below). We put the hashes at
the end of the line (where end of a line is defined by the global option
options()$strcode$char_length, which defaults to 80)
and separate it from the section title with spaces to
achieve a natural representation in the code flow.
Being recognised as sections by RStudio means
that at the very botton of the code pane, right next to line/indent count,
is a little table of contents of the current file which can be expanded to
view (and jump to) different code sections. Additionally, you will be able
to fold code sections (just as you can fold function declarations in RStudio).
sum_str
# This is a minimal example.
# See the readme for a longer and more detailed example.
## ......................................................
## A: pre-process t2 ####
### .. . . . . . . . . . . . . . . . . . . . . . . . . . .
### a: substep 1 ####
# [your code here]
### .. . . . . . . . . . . . . . . . . . . . . . . . . . .
### b: substep 2 ####
# [your code here ]
## ......................................................
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.