View source: R/colby_constructors.R
| split_rows_by_multivar | R Documentation |
When we need rows to reflect different variables rather than different
levels of a single variable, we use split_rows_by_multivar.
split_rows_by_multivar(
lyt,
vars,
split_fun = NULL,
split_label = "",
varlabels = vars,
parent_name = "multivars",
format = NULL,
na_str = NA_character_,
nested = TRUE,
at_sibling = NULL,
child_labels = c("default", "visible", "hidden"),
indent_mod = 0L,
section_div = NA_character_,
extra_args = list()
)
lyt |
( |
vars |
( |
split_fun |
( |
split_label |
( |
varlabels |
( |
parent_name |
( |
format |
( |
na_str |
( |
nested |
( |
at_sibling |
( |
child_labels |
( |
indent_mod |
( |
section_div |
( |
extra_args |
( |
A PreDataTableLayouts object suitable for passing to further layouting functions, and to build_table().
When nested is TRUE, at_sibling allows you to set a nesting
anchor that your new split_rows_by* or analyze* directive
should be placed as a sibling to. The lookup for this anchor
occurs only in the currently active top-level nesting stack,
meaning the directives that have occurred since
the last split or analysis with nested == FALSE.
Furthermore, resolution occurs against the first element of each
arm of a branching point caused by any previous uses of
at_sibling but only descends into the last arm.
So for example if our previous layout was generated via:
lyt <- basic_table() |>
split_rows_by("SEX") |>
analyze("AGE") |>
split_rows_by("BMRKR2", nested = FALSE) |>
split_rows_by("RACE") |>
analyze("AGE") |>
split_rows_by("SEX", at_sibling = "RACE") |>
analyze("BMRKR1")
The eligible anchor points would be "BMRKR2", "RACE", "SEX"
and "BMRKR1". "AGE" is masked by the branching caused by
anchoring our SEX split on RACE.
Finally, while at_sibling does support de-duplication of
"<name>[i]" anchors, it does so within the set of available
anchors, which can be counter-intuitive. It is strongly suggested
that the parent_name and table_names argument(s) of
split_rows_by* and analyze be used to prevent the need for
this. at_sibling will resolve to table names overridden in this
manner.
split_rows_by() for typical row splitting, and split_cols_by_multivar() to perform the same type of
split on a column basis.
lyt <- basic_table() |>
split_cols_by("ARM") |>
split_rows_by_multivar(c("SEX", "STRATA1")) |>
summarize_row_groups() |>
analyze(c("AGE", "SEX"))
tbl <- build_table(lyt, DM)
tbl
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.