prune_table: Recursively prune a 'TableTree'

View source: R/tt_compare_tables.R

prune_tableR Documentation

Recursively prune a TableTree

Description

Recursively prune a TableTree

Usage

prune_table(
  tt,
  prune_func = prune_empty_level,
  stop_depth = NA_real_,
  depth = 0
)

Arguments

tt

TableTree (or related class). A TableTree object representing a populated table.

prune_func

function. A Function to be called on each subtree which returns TRUE if the entire subtree should be removed.

stop_depth

numeric(1). The depth after which subtrees should not be checked for pruning. Defaults to NA which indicates pruning should happen at all levels

depth

numeric(1). Used internally, not intended to be set by the end user.

Value

A TableTree pruned via recursive application of prune_func.

See Also

prune_empty_level() for details on this and several other basic pruning functions included in the rtables package.

Examples

adsl <- ex_adsl
levels(adsl$SEX) <- c(levels(ex_adsl$SEX), "OTHER")

tbl_to_prune <- basic_table() %>%
    split_cols_by("ARM") %>% 
    split_rows_by("SEX") %>% 
    summarize_row_groups() %>%
    split_rows_by("STRATA1") %>%
    summarize_row_groups() %>%
    analyze("AGE") %>%
    build_table(adsl)

tbl_to_prune %>% prune_table()


rtables documentation built on Aug. 30, 2023, 5:07 p.m.