Extract a display-ready frame from a build result
as_display.RdReturns just the display content of a tplyr_build result — the
rowlabel*, res*, rdiff*, and pval* columns — and
drops the internal ordering helpers (ord_layer_index,
ord_layer_*) and the row_id metadata column, giving a frame
ready to hand to a table-rendering package (clinify, flextable, gt, ...). The
build output is already ordered, so no re-sorting is performed.
Arguments
- x
A data.frame produced by
tplyr_build.- labels
Logical. When
TRUE, theres*/rdiff*/pval*columns are renamed to their header labels (theirlabelattribute, as returned byget_data_labels); the row-label columns keep their names. Defaults toFALSE.
Examples
spec <- tplyr_spec(cols = "TRT", layers = tplyr_layers(group_count("SEX")))
b <- tplyr_build(spec, data.frame(TRT = rep(c("A", "B"), 3),
SEX = rep(c("F", "M"), 3)))
as_display(b)
#> rowlabel1 res1 res2
#> 1 F 3 (100.0%) 0 ( 0.0%)
#> 2 M 0 ( 0.0%) 3 (100.0%)