Create columns (or row splits) based on values (such as quartiles) of var
.
split_cols_by_cuts(
lyt,
var,
cuts,
cutlabels = NULL,
split_label = var,
nested = TRUE,
cumulative = FALSE
)split_rows_by_cuts(
lyt,
var,
cuts,
cutlabels = NULL,
split_label = var,
nested = TRUE,
cumulative = FALSE,
label_pos = "hidden"
)
split_cols_by_cutfun(
lyt,
var,
cutfun = qtile_cuts,
cutlabelfun = function(x) NULL,
split_label = var,
format = NULL,
nested = TRUE,
extra_args = list(),
cumulative = FALSE
)
split_cols_by_quartiles(
lyt,
var,
split_label = var,
format = NULL,
nested = TRUE,
extra_args = list(),
cumulative = FALSE
)
split_rows_by_quartiles(
lyt,
var,
split_label = var,
format = NULL,
nested = TRUE,
child_labels = c("default", "visible", "hidden"),
extra_args = list(),
cumulative = FALSE,
indent_mod = 0L,
label_pos = "hidden"
)
split_rows_by_cutfun(
lyt,
var,
cutfun = qtile_cuts,
cutlabelfun = function(x) NULL,
split_label = var,
format = NULL,
nested = TRUE,
child_labels = c("default", "visible", "hidden"),
extra_args = list(),
cumulative = FALSE,
indent_mod = 0L,
label_pos = "hidden"
)
A PreDataTableLayouts
object suitable for passing to further layouting functions, and to build_table
.
layout object pre-data used for tabulation
string, variable name
numeric. Cuts to use
character (or NULL). Labels for the cutst
string. Label string to be associated with the table generated by the split. Not to be confused with labels assigned to each child (which are based on the data and type of split during tabulation).
boolean. Should this layout instruction be applied within the existing layout structure if possible (TRUE
, the default) or as a new top-level element (`FALSE). Ignored if it would nest a split underneath analyses, which is not allowed.
logical. Should the cuts be treated as cumulative. Defaults to FALSE
character(1). Location the variable label should be displayed, Accepts hidden (default for non-analyze row splits), visible, topleft, and - for analyze splits only - default. For analyze calls, default
indicates that the variable
should be visible if and only if multiple variables are analyzed at the same level of nesting.
function. Function which accepts the full vector of var
values and returns cut points to be passed to cut
.
function. Function which returns either labels for the cuts or NULL when passed the return value of cutfun
FormatSpec. Format associated with this split. Formats can be declared via strings ("xx.x"
) or function. In cases such as analyze
calls, they can character vectors or lists of functions.
list. Extra arguments to be passed to the tabulation function. Element position in thte list corresponds to the children of this split. Named elements in the child-specific lists are ignored if they do not match a formal argument of the ttabulation function.
string. One of "default"
, "visible"
, "hidden"
. What should the display behavior be for the labels (ie label rows) of the children of this split. Defaults to "default"
which flags the label row as visible only if the child has 0 content rows.
numeric. Modifier for the default indent position for the structure created by this function(subtable, content table, or row) and all of that structure's children. Defaults to 0, which corresponds to the unmodified default behavior.
Gabriel Becker
For dynamic cuts, the cut is transformed into a static cut by build_table
based on the full
dataset, before proceeding. Thus even when nested within another split in column/row space, the resulting split will
reflect the overall vaalues (e.g., quartiles) in the dataset, NOT the values for subset it is nested under.
library(dplyr)
# split_cols_by_cuts
l <- basic_table() %>%
split_cols_by("ARM") %>%
split_cols_by_cuts("AGE", split_label = "Age",
cuts = c(0, 25, 35, 1000),
cutlabels = c("young", "medium", "old")) %>%
analyze(c("BMRKR2", "STRATA2")) %>%
append_topleft("counts")
build_table(l, ex_adsl)
# split_rows_by_cuts
l <- basic_table() %>%
split_cols_by("ARM") %>%
split_rows_by_cuts("AGE", split_label = "Age",
cuts = c(0, 25, 35, 1000),
cutlabels = c("young", "medium", "old")) %>%
analyze(c("BMRKR2", "STRATA2")) %>%
append_topleft("counts")
build_table(l, ex_adsl)
# split_cols_by_quartiles
l <- basic_table() %>%
split_cols_by("ARM") %>%
split_cols_by_quartiles("AGE", split_label = "Age") %>%
analyze(c("BMRKR2", "STRATA2")) %>%
append_topleft("counts")
build_table(l, ex_adsl)
# split_rows_by_quartiles
l <- basic_table() %>%
split_cols_by("ARM") %>%
add_colcounts() %>%
split_rows_by_quartiles("AGE", split_label = "Age") %>%
analyze("BMRKR2") %>%
append_topleft(c("Age Quartiles", " Counts BMRKR2"))
build_table(l, ex_adsl)
Run the code above in your browser using DataLab