all_zero_or_na | R Documentation |
Criteria functions (and constructors thereof) for trimming and pruning tables.
all_zero_or_na(tr)
all_zero(tr)
content_all_zeros_nas(tt, criteria = all_zero_or_na)
prune_empty_level(tt)
prune_zeros_only(tt)
low_obs_pruner(min, type = c("sum", "mean"))
tr |
|
tt |
|
criteria |
function. Function which takes a |
min |
numeric(1). ( |
type |
character(1). How count values should be aggregated. Must be
|
all_zero_or_na
returns TRUE
(and thus indicates
trimming/pruning) for any non-LabelRow
TableRow
which contain
only any mix of NA
(including NaN
), 0
, Inf
and
-Inf
values.
all_zero
returns TRUE
for any non-Label row which
contains only (non-missing) zero values.
content_all_zeros_nas
Prunes a subtable if a) it has a
content table with exactly one row in it, and b) all_zero_or_na
returns TRUE
for that single content row. In practice, when the
default summary/content function is used, this represents pruning any
subtable which corresponds to an empty set of the input data (e.g., because
a factor variable was used in split_rows_by
but not all
levels were present in the data).
prune_empty_level
combines all_zero_or_na
behavior for
TableRow
objects, content_all_zeros_nas
on
content_table(tt)
for TableTree
objects, and an additional
check that returns TRUE
if the tt
has no children.
prune_zeros_only
behaves as prune_empty_level
does,
except that like all_zero
it prunes only in the case of all
non-missing zero values.
low_obs_pruner
is a constructor function which, when
called, returns a pruning criteria function which will prune on content
rows by comparing sum or mean (dictated by type
) of the count
portions of the cell values (defined as the first value per cell regardless
of how many values per cell there are) against min
.
A logical value indicating whether tr
should be included
(TRUE
) or pruned (FALSE
) during pruning.
prune_table()
, trim_rows()
adsl <- ex_adsl
levels(adsl$SEX) <- c(levels(ex_adsl$SEX), "OTHER")
adsl$AGE[adsl$SEX == "UNDIFFERENTIATED"] <- 0
adsl$BMRKR1 <- 0
tbl_to_prune <- 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_prune %>% prune_table(all_zero_or_na)
tbl_to_prune %>% prune_table(all_zero)
tbl_to_prune %>% prune_table(content_all_zeros_nas)
tbl_to_prune %>% prune_table(prune_empty_level)
tbl_to_prune %>% prune_table(prune_zeros_only)
min_prune <- low_obs_pruner(70, "sum")
tbl_to_prune %>% prune_table(min_prune)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.