Learn R Programming

rtables (version 0.4.0)

analyze_against_ref_group: Add ref_group comparison analysis recipe

Description

Add ref_group comparison analysis recipe

Usage

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")
)

Arguments

lyt

layout object pre-data used for tabulation

var

string, variable name

afun

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.

label

character(1). A label (not to be confused with the name) for the object/structure.

compfun

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.

format

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.

nested

boolean, Add this as a new top-level split (defining a new subtable directly under root). Defaults to FALSE

indent_mod

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.

show_labels

character(1). Should the variable labels for corresponding to the variable(s) in vars be visible in the resulting table.

Value

A PreDataTableLayouts object suitable for passing to further layouting functions, and to build_table.

Details

Please see the baseline vignette for more details.

Examples

Run this code
# 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