trim_rows: Trim rows from a populated table without regard for table...

View source: R/tt_compare_tables.R

trim_rowsR Documentation

Trim rows from a populated table without regard for table structure

Description

Trim rows from a populated table without regard for table structure

Usage

trim_rows(tt, criteria = all_zero_or_na)

Arguments

tt

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

criteria

function. Function which takes a TableRow object and returns TRUE if that row should be removed. Defaults to all_zero_or_na

Details

This function will be deprecated in the future in favor of the more elegant and versatile prune_table() function which can perform the same function as trim_rows() but is more powerful as it takes table structure into account.

Value

The table with rows that have only NA or 0 cell values removed

Note

Visible LabelRows are including in this trimming, which can lead to either all label rows being trimmed or label rows remaining when all data rows have been trimmed, depending on what criteria returns when called on a LabelRow object. To avoid this, use the structurally-aware prune_table machinery instead.

See Also

prune_table()

Examples

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

tbl_to_trim <- basic_table() %>%
    analyze("BMRKR1") %>%
    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_trim %>% trim_rows()

tbl_to_trim %>% trim_rows(all_zero)


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