| clin_spanner_rule | R Documentation |
Regulatory arm spanner tables carry a thin horizontal rule directly under each spanner label, running across only the columns that spanner covers, so that the label reads as a heading over its own block of columns. The columns are worked out from the header that is on the table, so the rule follows the spanners as the layout changes instead of having to be given as column numbers that then have to be kept in step with it.
clin_spanner_rule(x, border = TRUE, rows = NULL)
x |
A clintable object |
border |
The pen to draw the rule with. |
rows |
Header rows to rule, numbered from the top down. |
A spanner is a run of header cells that has been merged together, which is
what clin_column_headers() makes of adjacent cells holding the same text.
Two kinds of run are deliberately left alone:
A run of blank cells. That is the empty space over a stub column, or over a trailing p-value column, rather than a spanner - clinify fills the header levels a column does not use, so those cells merge into a run of their own.
Anything in the bottom row of the header. That row holds the individual column labels, so a merged run in it is a label sitting over two columns rather than a spanner, and the rule under the bottom row is the one the styling function draws across the whole table.
Called a second time, this refines what the first call set rather than replacing it: arguments this call does not name keep their earlier value.
The rule is drawn as the table renders, after the default styling function
has run. That is what makes it survive a house style: the stock
clinify_table_default() opens with flextable::border_remove(), which
would wipe a border applied any earlier, and a house style is free to draw
its header rules in a pen of its own.
A clintable object
df <- data.frame(
stub = c("Male", "Female"),
a_lo = c("5 (10%)", "7 (14%)"),
a_hi = c("2 (4%)", "3 (6%)"),
b_lo = c("6 (12%)", "8 (16%)"),
b_hi = c("1 (2%)", "4 (8%)")
)
ct <- clintable(df, use_labels = FALSE) |>
clin_column_headers(
stub = "",
a_lo = c("Drug A (N=50)", "Low"),
a_hi = c("Drug A (N=50)", "High"),
b_lo = c("Drug B (N=50)", "Low"),
b_hi = c("Drug B (N=50)", "High")
)
# A rule under each arm spanner, over that arm's two columns only, with the
# stub left un-ruled
clin_spanner_rule(ct)
# The same rule in a dashed pen
clin_spanner_rule(ct, border = officer::fp_border(style = "dashed"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.