View source: R/label_template.R
| label_template | R Documentation |
Returns a named character vector covering all factor IDs in the object,
ready to pass to autoplot(x, node_labels = ...). Printing the result
shows an editable c(...) literal so you can copy it into a script,
fill in substantive labels, and use it directly; assigning the result
(labs <- label_template(x)) produces no console output.
label_template(x, style = c("id", "forbes", "blank"))
## S3 method for class 'ackwards_labels'
print(x, ...)
x |
An |
style |
One of |
... |
Ignored; included for S3 method consistency. |
The factor IDs are returned in the same left-to-right, top-to-bottom order
used by ba_layout() and autoplot.ackwards(), so the printed literal maps
directly onto the diagram.
A named character vector of class "ackwards_labels": names are
factor IDs ("m{k}f{j}"), values are the label strings for the chosen
style. The vector is suitable for direct use as the node_labels
argument to autoplot.ackwards(). Its print() method renders the
vector as an editable c(...) literal for copy-paste.
"id" (default) – every value equals the factor ID ("m1f1", "m2f1",
...). This is a round-trip no-op: passing the result to node_labels without
editing reproduces the default labels exactly. Useful as the starting point
for adding substantive labels.
"forbes" – values follow the Forbes (2023) convention: level-letter +
within-level index ("A1", "B1", "B2", ...). Level 1 -> A, level 2 ->
B, level 3 -> C, and so on. Within-level indices are assigned in
canonical layout order (left to right). Requires k_max <= 26 (LETTERS has
26 entries); an error is raised for deeper objects.
"blank" – all values are empty strings. Useful as a starting scaffold
when you want to supply every label from scratch with no defaults showing
through.
autoplot.ackwards(), top_items(), ba_layout()
x <- ackwards(sim16, k_max = 5)
# Start from ID defaults, then fill in your own labels:
labs <- label_template(x)
labs["m5f1"] <- "My factor name"
# Forbes letter convention:
label_template(x, style = "forbes")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.