abnormal_by_baseline | R Documentation |
Primary analysis variable .var
indicates the abnormal range result (character
or factor
), and additional
analysis variables are id
(character
or factor
) and baseline
(character
or factor
). For each
direction specified in abnormal
(e.g. high or low) we condition on baseline range result and count
patients in the numerator and denominator as follows:
Not <Abnormal>
denom
: the number of patients without abnormality at baseline (excluding those with missing baseline)
num
: the number of patients in denom
who also have at least one abnormality post-baseline
<Abnormal>
denom
: the number of patients with abnormality at baseline
num
: the number of patients in denom
who also have at least one abnormality post-baseline
Total
denom
: the number of patients with at least one valid measurement post-baseline
num
: the number of patients in denom
who also have at least one abnormality post-baseline
count_abnormal_by_baseline(
lyt,
var,
abnormal,
variables = list(id = "USUBJID", baseline = "BNRIND"),
na_str = "<Missing>",
nested = TRUE,
...,
table_names = abnormal,
.stats = NULL,
.formats = NULL,
.labels = NULL,
.indent_mods = NULL
)
s_count_abnormal_by_baseline(
df,
.var,
abnormal,
na_str = "<Missing>",
variables = list(id = "USUBJID", baseline = "BNRIND")
)
a_count_abnormal_by_baseline(
df,
.var,
abnormal,
na_str = "<Missing>",
variables = list(id = "USUBJID", baseline = "BNRIND")
)
lyt |
( |
abnormal |
( |
variables |
(named |
na_str |
( |
nested |
( |
... |
additional arguments for the lower level functions. |
table_names |
( |
.stats |
( |
.formats |
(named |
.labels |
(named |
.indent_mods |
(named |
df |
( |
.var , var |
( |
count_abnormal_by_baseline()
returns a layout object suitable for passing to further layouting functions,
or to rtables::build_table()
. Adding this function to an rtable
layout will add formatted rows containing
the statistics from s_count_abnormal_by_baseline()
to the table layout.
s_count_abnormal_by_baseline()
returns statistic fraction
which is a named list with 3 labeled elements:
not_abnormal
, abnormal
, and total
. Each element contains a vector with num
and denom
patient counts.
a_count_abnormal_by_baseline()
returns the corresponding list with formatted rtables::CellValue()
.
count_abnormal_by_baseline()
: Layout-creating function which can take statistics function arguments
and additional format arguments. This function is a wrapper for rtables::analyze()
.
s_count_abnormal_by_baseline()
: Statistics function for a single abnormal
level.
a_count_abnormal_by_baseline()
: Formatted analysis function which is used as afun
in count_abnormal_by_baseline()
.
df
should be filtered to include only post-baseline records.
If the baseline variable or analysis variable contains NA
, it is expected that NA
has been
conveyed to na_level
appropriately beforehand with df_explicit_na()
or explicit_na()
.
Relevant description function d_count_abnormal_by_baseline()
.
df <- data.frame(
USUBJID = as.character(c(1:6)),
ANRIND = factor(c(rep("LOW", 4), "NORMAL", "HIGH")),
BNRIND = factor(c("LOW", "NORMAL", "HIGH", NA, "LOW", "NORMAL"))
)
df <- df_explicit_na(df)
# Layout creating function.
basic_table() %>%
count_abnormal_by_baseline(var = "ANRIND", abnormal = c(High = "HIGH")) %>%
build_table(df)
# Passing of statistics function and formatting arguments.
df2 <- data.frame(
ID = as.character(c(1, 2, 3, 4)),
RANGE = factor(c("NORMAL", "LOW", "HIGH", "HIGH")),
BLRANGE = factor(c("LOW", "HIGH", "HIGH", "NORMAL"))
)
basic_table() %>%
count_abnormal_by_baseline(
var = "RANGE",
abnormal = c(Low = "LOW"),
variables = list(id = "ID", baseline = "BLRANGE"),
.formats = c(fraction = "xx / xx"),
.indent_mods = c(fraction = 2L)
) %>%
build_table(df2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.