init_text_builder | R Documentation |
text_builder
object, used for incrementally adding text partsThis function is very useful, when you want to incrementally add text
parts to a string.
The text_builder
mechanism uses two separate text stacks in order to
store added text parts:
A downward stack
: For this stack all new text parts will be added below the
previously added text parts. With add_text()
new text parts can be added
to this text stack.
An upward stack
: This stack uses the inverse direction, therefore
all new text parts will be added above the previously added text parts.
With add_text_end()
new text parts can be added to the upward stack
.
When calling create_text()
the downward stack
is concatenated above
the upward stack
.
The function init_text_builder()
returns a list object holding the following functions
add_text(text, indent_level = 0)
: This function adds a text part
to the text stack, holding all text parts you have added so far.
It takes two arguments:
text
: A character vector holding the text parts you want to add.
indent_level
: A non-negative integer, which defines how many times
you want to add the indentation string (defined in indent
) in front
of the added text part.
add_text_end(text, indent_level = 0)
: This function is similar to
add_text()
, but adds the text part to the upward stack
.
It takes two arguments:
text
: A character vector holding the text parts you want to add.
Be careful, although the upward stack
has reversed direction, the
string entries in the character vector text
are not reversed.
This means that for add_text_end(c("bla", "blub"))
the string
"bla"
comes also in the finally builded text before "blub"
.
indent_level
: A non-negative integer, which defines how many times
you want to add the indentation string (defined in indent
) in front
of the added text part.
create_text()
: This function returns the constructed text.
init_text_builder(sep = "\n", indent = "\t", before = NULL, after = NULL)
sep |
A string, which will automatically be inserted between
two added text parts If you want to use no separator symbol at all, then
just set |
indent |
A string, used as indentation symbol. This symbol will
automatically be inserted zero, one or multiple times in front of an
added text part, depending on the used |
before |
A string, which will automatically be added right in front of each text part. |
after |
A string, which will automatically be added right after each text part. |
A list object holding the function add_text()
and get_text()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.