count_cumulative {tern} | R Documentation |
Cumulative counts of numeric variable by thresholds
Description
The analyze function count_cumulative()
creates a layout element to calculate cumulative counts of values in a
numeric variable that are less than, less or equal to, greater than, or greater or equal to user-specified
threshold values.
This function analyzes numeric variable vars
against the threshold values supplied to the thresholds
argument as a numeric vector. Whether counts should include the threshold values, and whether to count
values lower or higher than the threshold values can be set via the include_eq
and lower_tail
parameters, respectively.
Usage
count_cumulative(
lyt,
vars,
thresholds,
lower_tail = TRUE,
include_eq = TRUE,
var_labels = vars,
show_labels = "visible",
na_str = default_na_str(),
nested = TRUE,
...,
table_names = vars,
.stats = NULL,
.formats = NULL,
.labels = NULL,
.indent_mods = NULL
)
s_count_cumulative(
x,
thresholds,
lower_tail = TRUE,
include_eq = TRUE,
.N_col,
...
)
a_count_cumulative(
x,
thresholds,
lower_tail = TRUE,
include_eq = TRUE,
.N_col,
...
)
Arguments
lyt |
( |
vars |
( |
thresholds |
( |
lower_tail |
( |
include_eq |
( |
var_labels |
( |
show_labels |
( |
na_str |
( |
nested |
( |
... |
additional arguments for the lower level functions. |
table_names |
( |
.stats |
( |
.formats |
(named |
.labels |
(named |
.indent_mods |
(named |
x |
( |
.N_col |
( |
Value
-
count_cumulative()
returns a layout object suitable for passing to further layouting functions, or tortables::build_table()
. Adding this function to anrtable
layout will add formatted rows containing the statistics froms_count_cumulative()
to the table layout.
-
s_count_cumulative()
returns a named list ofcount_fraction
s: a list with eachthresholds
value as a component, each component containing a vector for the count and fraction.
-
a_count_cumulative()
returns the corresponding list with formattedrtables::CellValue()
.
Functions
-
count_cumulative()
: Layout-creating function which can take statistics function arguments and additional format arguments. This function is a wrapper forrtables::analyze()
. -
s_count_cumulative()
: Statistics function that produces a named list given a numeric vector of thresholds. -
a_count_cumulative()
: Formatted analysis function which is used asafun
incount_cumulative()
.
See Also
Relevant helper function h_count_cumulative()
, and descriptive function d_count_cumulative()
.
Examples
basic_table() %>%
split_cols_by("ARM") %>%
add_colcounts() %>%
count_cumulative(
vars = "AGE",
thresholds = c(40, 60)
) %>%
build_table(tern_ex_adsl)