Add ref_group comparison analysis recipe
analyze_against_ref_group(
lyt,
var = NA_character_,
afun,
label = if (is.na(var)) "" else var,
compfun = `-`,
format = NULL,
nested = TRUE,
indent_mod = 0L,
show_labels = c("default", "hidden", "visible")
)
layout object pre-data used for tabulation
string, variable name
function. Analysis function, must take x
or df
as its first parameter. Can optionally take other parameters which will be populated by the tabulation framework. See Details in analyze
.
character(1). A label (not to be confused with the name) for the object/structure.
function/string. The comparison function which accepts the analysis function outputs for two different partitions and returns a single value. Defaults to subraction. If a string, taken as the name of a function.
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.
boolean, Add this as a new top-level split (defining a new subtable directly under root). Defaults to FALSE
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.
character(1). Should the variable labels for corresponding to the variable(s) in vars
be visible in the resulting table.
A PreDataTableLayouts
object suitable for passing to further layouting functions, and to build_table
.
Please see the baseline
vignette for more details.
# NOT RUN {
basic_table() %>%
split_cols_by("ARM", ref_group = "B: Placebo") %>%
analyze("AGE", afun = function(x, .ref_group) {
in_rows(
"Difference of Averages" = rcell(mean(x) - mean(.ref_group), format = "xx.xx")
)
}) %>%
build_table(DM)
# }
Run the code above in your browser using DataLab